diff --git a/src/bloom.erl b/src/bloom.erl index 9aec56b..8b61dd1 100644 --- a/src/bloom.erl +++ b/src/bloom.erl @@ -63,12 +63,13 @@ is_element(Key, B, [Idx | T]) -> %% @doc Adds the key to the filter. -spec add_element(term(), #bloom{}) -> #bloom{}. -add_element(Key, #bloom{keys=Keys, n=N, bitmap=Bitmap} = B) when Keys < N -> +add_element(Key, #bloom{keys=Keys, n=N, bitmap=Bitmap}=B) + when Keys < N -> Idxs = calc_idxs(Key, B), Bitmap0 = set_bits(Bitmap, Idxs), case Bitmap0 == Bitmap of true -> B#bloom{bitmap=Bitmap0}; % Don't increment key count for duplicates. - false -> B#bloom{bitmap=Bitmap0, keys=Keys+1} + false -> B#bloom{bitmap=Bitmap0, keys=Keys + 1} end. %% @internal @@ -82,11 +83,6 @@ set_bits(Bin, [Idx | Idxs]) -> Byte0 = Byte bor Mask, set_bits(<
>, Idxs).
 
-%set_bits(Bin, [Idx | Idxs]) ->
-%    <> = Bin,
-%    set_bits(<
>, Idxs).
-
-
 %% @internal
 %% @doc Find the optimal bitmap size and number of hashes.
 %TODO -spec(non_neg_integer(), number()) -> non_neg_integer().