diff options
author | Christian Grothoff <christian@grothoff.org> | 2021-11-30 19:33:38 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2021-11-30 19:33:38 +0100 |
commit | 851f794c617b6b95af8c69b72524f10b9ade131c (patch) | |
tree | 931682e04877a89084ae408ec1efd49d87193d1e | |
parent | f80d6d695a76113ce5537592539bf38c35367fd7 (diff) | |
download | gnunet-851f794c617b6b95af8c69b72524f10b9ade131c.tar.gz gnunet-851f794c617b6b95af8c69b72524f10b9ade131c.zip |
-nicer code
-rw-r--r-- | src/util/container_bloomfilter.c | 26 |
1 files 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, | |||
380 | void *arg, | 380 | void *arg, |
381 | const struct GNUNET_HashCode *key) | 381 | const struct GNUNET_HashCode *key) |
382 | { | 382 | { |
383 | struct GNUNET_HashCode tmp[2]; | 383 | struct GNUNET_HashCode tmp = *key; |
384 | int bitCount; | 384 | int bitCount; |
385 | unsigned int round; | ||
386 | unsigned int slot = 0; | 385 | unsigned int slot = 0; |
387 | 386 | ||
388 | bitCount = bf->addressesPerElement; | 387 | bitCount = bf->addressesPerElement; |
389 | tmp[0] = *key; | ||
390 | round = 0; | ||
391 | GNUNET_assert (bf->bitArraySize > 0); | 388 | GNUNET_assert (bf->bitArraySize > 0); |
392 | GNUNET_assert (bf->bitArraySize * 8LL > bf->bitArraySize); | 389 | GNUNET_assert (bf->bitArraySize * 8LL > bf->bitArraySize); |
393 | while (bitCount > 0) | 390 | while (bitCount > 0) |
394 | { | 391 | { |
395 | while (slot < (sizeof(struct GNUNET_HashCode) / sizeof(uint32_t))) | 392 | while ( (0 != bitCount) && |
393 | (slot < (sizeof(struct GNUNET_HashCode) / sizeof(uint32_t))) ) | ||
396 | { | 394 | { |
397 | if (GNUNET_YES != | 395 | if (GNUNET_YES != |
398 | callback (arg, | 396 | callback (arg, |
399 | bf, | 397 | bf, |
400 | ntohl ((((uint32_t *) &tmp[round & 1])[slot])) | 398 | ntohl ((((uint32_t *) &tmp)[slot])) |
401 | % ((bf->bitArraySize * 8LL)))) | 399 | % ((bf->bitArraySize * 8LL)))) |
402 | return; | 400 | return; |
403 | slot++; | 401 | slot++; |
404 | bitCount--; | 402 | bitCount--; |
405 | if (bitCount == 0) | ||
406 | break; | ||
407 | } | ||
408 | if (bitCount > 0) | ||
409 | { | ||
410 | GNUNET_CRYPTO_hash (&tmp[round & 1], | ||
411 | sizeof(struct GNUNET_HashCode), | ||
412 | &tmp[(round + 1) & 1]); | ||
413 | round++; | ||
414 | slot = 0; | ||
415 | } | 403 | } |
404 | if (0 == bitCount) | ||
405 | break; | ||
406 | GNUNET_CRYPTO_hash (&tmp, | ||
407 | sizeof(tmp), | ||
408 | &tmp); | ||
409 | slot = 0; | ||
416 | } | 410 | } |
417 | } | 411 | } |
418 | 412 | ||