]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Add another implementation of node_add_potential_bucket()
authorIgor Putovny <igor.putovny@nic.cz>
Thu, 20 Feb 2025 16:16:17 +0000 (17:16 +0100)
committerIgor Putovny <igor.putovny@nic.cz>
Thu, 20 Feb 2025 16:16:17 +0000 (17:16 +0100)
proto/aggregator/aggregator.c

index 31dd252247bcaa546aae862c98ae89c4561ed02a..1cfc49b7451291b139fb3b7fb88c0534b3eee705 100644 (file)
@@ -151,11 +151,29 @@ node_add_potential_bucket(struct trie_node *node, const struct aggregator_bucket
 {
   assert(node->potential_buckets_count < MAX_POTENTIAL_BUCKETS_COUNT);
 
+  /*
   if (BIT32R_TEST(node->potential_buckets, bucket->id))
     return;
 
   BIT32R_SET(node->potential_buckets, bucket->id);
   node->potential_buckets_count++;
+  */
+
+  /*
+   * If the bit is set, the result of TEST is 1 and is subtracted from
+   * the bucket count, decreasing it by one.
+   * Second statement has no effect since the bit is already set.
+   * Third statement increases count by one, returning it to its previous
+   * value. Nothing changed.
+   *
+   * If the bit is not set, the result of TEST is 0 and subtracting it
+   * from the total count doesn't change its value.
+   * Second statement sets the bit and third statement increases count by one.
+   * Bit is now set and the total count was increased by one.
+   */
+  node->potential_buckets_count -= BIT32R_TEST(node->potential_buckets, bucket->id);
+  BIT32R_SET(node->potential_buckets, bucket->id);
+  node->potential_buckets_count++;
 }
 
 /*