gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] 01/02: -nicer code


From: gnunet
Subject: [gnunet] 01/02: -nicer code
Date: Tue, 30 Nov 2021 20:05:49 +0100

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

grothoff pushed a commit to branch master
in repository gnunet.

commit 851f794c617b6b95af8c69b72524f10b9ade131c
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Nov 30 19:33:38 2021 +0100

    -nicer code
---
 src/util/container_bloomfilter.c | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/src/util/container_bloomfilter.c b/src/util/container_bloomfilter.c
index d7460043d..d89b46252 100644
--- a/src/util/container_bloomfilter.c
+++ b/src/util/container_bloomfilter.c
@@ -380,39 +380,33 @@ iterateBits (const struct GNUNET_CONTAINER_BloomFilter 
*bf,
              void *arg,
              const struct GNUNET_HashCode *key)
 {
-  struct GNUNET_HashCode tmp[2];
+  struct GNUNET_HashCode tmp = *key;
   int bitCount;
-  unsigned int round;
   unsigned int slot = 0;
 
   bitCount = bf->addressesPerElement;
-  tmp[0] = *key;
-  round = 0;
   GNUNET_assert (bf->bitArraySize > 0);
   GNUNET_assert (bf->bitArraySize * 8LL > bf->bitArraySize);
   while (bitCount > 0)
   {
-    while (slot < (sizeof(struct GNUNET_HashCode) / sizeof(uint32_t)))
+    while ( (0 != bitCount) &&
+            (slot < (sizeof(struct GNUNET_HashCode) / sizeof(uint32_t))) )
     {
       if (GNUNET_YES !=
           callback (arg,
                     bf,
-                    ntohl ((((uint32_t *) &tmp[round & 1])[slot]))
+                    ntohl ((((uint32_t *) &tmp)[slot]))
                     % ((bf->bitArraySize * 8LL))))
         return;
       slot++;
       bitCount--;
-      if (bitCount == 0)
-        break;
-    }
-    if (bitCount > 0)
-    {
-      GNUNET_CRYPTO_hash (&tmp[round & 1],
-                          sizeof(struct GNUNET_HashCode),
-                          &tmp[(round + 1) & 1]);
-      round++;
-      slot = 0;
     }
+    if (0 == bitCount)
+      break;
+    GNUNET_CRYPTO_hash (&tmp,
+                        sizeof(tmp),
+                        &tmp);
+    slot = 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]