bloom: if we're not setting bits, break after first failed mask check
authorJens Axboe <axboe@fb.com>
Tue, 7 Feb 2017 22:10:26 +0000 (15:10 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 7 Feb 2017 22:10:26 +0000 (15:10 -0700)
Signed-off-by: Jens Axboe <axboe@fb.com>
lib/bloom.c

index 7a9ebaa9360ce4285a15d2129fa859e45b9c4ee5..bb81dbbdf8c9b285b1f43f3b339f346a90881a63 100644 (file)
@@ -104,8 +104,10 @@ static bool __bloom_check(struct bloom *b, const void *data, unsigned int len,
 
                if (b->map[index] & (1U << bit))
                        was_set++;
-               if (set)
+               else if (set)
                        b->map[index] |= 1U << bit;
+               else
+                       break;
        }
 
        return was_set == N_HASHES;