From: Igor Putovny Date: Thu, 20 Feb 2025 16:16:17 +0000 (+0100) Subject: Add another implementation of node_add_potential_bucket() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=092f6ae4889969b9774adf4c9d7e8ed7d8d6b54b;p=thirdparty%2Fbird.git Add another implementation of node_add_potential_bucket() --- diff --git a/proto/aggregator/aggregator.c b/proto/aggregator/aggregator.c index 31dd25224..1cfc49b74 100644 --- a/proto/aggregator/aggregator.c +++ b/proto/aggregator/aggregator.c @@ -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++; } /*