gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet] 162/164: Iproved ibf counter packing code


From: gnunet
Subject: [gnunet] 162/164: Iproved ibf counter packing code
Date: Fri, 30 Jul 2021 15:33:48 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

commit 105e57bec066ee3e23286fd28eba852f2e15d6f7
Author: Elias Summermatter <elias.summermatter@seccom.ch>
AuthorDate: Thu Jun 17 10:03:14 2021 +0200

    Iproved ibf counter packing code
---
 src/setu/ibf.c | 50 +++++++++++++++-----------------------------------
 1 file changed, 15 insertions(+), 35 deletions(-)

diff --git a/src/setu/ibf.c b/src/setu/ibf.c
index 628b00e96..8cb899a38 100644
--- a/src/setu/ibf.c
+++ b/src/setu/ibf.c
@@ -385,47 +385,27 @@ pack_counter (const struct InvertibleBloomFilter *ibf,
     uint64_t count_val_to_write = ibf->count[i].count_val;
     uint8_t count_len_to_write = counter_max_length;
 
-    while (count_len_to_write > 0)
+    while ((count_len_to_write + store_size) >= 8)
     {
-      uint8_t byte_to_write = 0;
-
-      if ((count_len_to_write + store_size) >= 8)
-      {
-        uint8_t bit_shift = 0;
-        if ((store_size > 0) || (count_len_to_write > 8))
-        {
-          uint8_t bit_unused = 8 - store_size;
-          bit_shift = count_len_to_write - bit_unused;
-          store = store << bit_unused;
-        }
-
-        byte_to_write = ((count_val_to_write >> bit_shift) | store) & 0xFF;
-        count_len_to_write -= (8 - store_size);
-        count_val_to_write = count_val_to_write & ((1ULL <<
-                                                    count_len_to_write) - 1);
-
-        store = 0;
-        store_size = 0;
-      }
-      else
+      uint8_t bit_shift = 0;
+      if ((store_size > 0) || (count_len_to_write > 8))
       {
-        if (0 == store)
-        {
-          store = count_val_to_write;
-        }
-        else
-        {
-          store = (store << count_len_to_write) | count_val_to_write;
-        }
-        store_size = store_size + count_len_to_write;
-        count_len_to_write -= count_len_to_write;
-
-        break;
+        uint8_t bit_unused = 8 - store_size;
+        bit_shift = count_len_to_write - bit_unused;
+        store = store << bit_unused;
       }
 
-      buf[byte_ctr] = byte_to_write;
+      buf[byte_ctr] = ((count_val_to_write >> bit_shift) | store) & 0xFF;
       byte_ctr++;
+      count_len_to_write -= (8 - store_size);
+      count_val_to_write = count_val_to_write & ((1ULL <<
+                                                  count_len_to_write) - 1);
+      store = 0;
+      store_size = 0;
     }
+    store = (store << count_len_to_write) | count_val_to_write;
+    store_size = store_size + count_len_to_write;
+    count_len_to_write = 0;
     i++;
   }
   if (store_size > 0)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]