<p>fixeria has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/libosmocore/+/26309">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">bitvec_read_field(): optimize by expanding bytenum_from_bitnum()<br><br>The bitvec_read_field() is used in performance critical places,<br>such as the CSN.1 decoder in osmo-pcu.  Thus the less conditional<br>statements we have in the parsing loop, the better.<br><br>The bitvec_get_bit_pos() alone is quite a complex function, which<br>does check the boundaries and even supports the L/H syntax.  Even<br>if it gets inlined by the compiler, we don't really want to run<br>redundant checks and run bitval2mask() on each iteration.<br><br>Change-Id: I438fc82d33ab2edbabd4215ec7bc46afb07d50ab<br>---<br>M src/bitvec.c<br>1 file changed, 4 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/09/26309/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/bitvec.c b/src/bitvec.c</span><br><span>index 2303a0d..13deeff 100644</span><br><span>--- a/src/bitvec.c</span><br><span>+++ b/src/bitvec.c</span><br><span>@@ -491,8 +491,10 @@</span><br><span>       errno = 0;</span><br><span> </span><br><span>       for (i = 0; i < len; i++) {</span><br><span style="color: hsl(0, 100%, 40%);">-          int bit = bitvec_get_bit_pos((const struct bitvec *)bv, bv->cur_bit);</span><br><span style="color: hsl(0, 100%, 40%);">-                if (bit)</span><br><span style="color: hsl(120, 100%, 40%);">+              unsigned int bytenum = bytenum_from_bitnum(bv->cur_bit);</span><br><span style="color: hsl(120, 100%, 40%);">+           unsigned int bitnum = 7 - (bv->cur_bit % 8);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+             if (bv->data[bytenum] & (1 << bitnum))</span><br><span>                  ui |= ((uint64_t)1 << (len - i - 1));</span><br><span>          bv->cur_bit++;</span><br><span>    }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/libosmocore/+/26309">change 26309</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/libosmocore/+/26309"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I438fc82d33ab2edbabd4215ec7bc46afb07d50ab </div>
<div style="display:none"> Gerrit-Change-Number: 26309 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>