Skip to content

Commit

Permalink
vclock:equal/2: Much simpler, much faster (25x).
Browse files Browse the repository at this point in the history
  • Loading branch information
esstrifork committed Jul 8, 2011
1 parent 945fd24 commit 265a185
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/vclock.erl
Expand Up @@ -142,19 +142,9 @@ timestamp() ->
calendar:datetime_to_gregorian_seconds(erlang:universaltime()).

% @doc Compares two VClocks for equality.
% Not very fast.
-spec equal(VClockA :: vclock(), VClockB :: vclock()) -> boolean().
equal(VA,VB) ->
VSet1 = sets:from_list(VA),
VSet2 = sets:from_list(VB),
case sets:size(sets:subtract(VSet1,VSet2)) > 0 of
true -> false;
false ->
case sets:size(sets:subtract(VSet2,VSet1)) > 0 of
true -> false;
false -> true
end
end.
lists:sort(VA) =:= lists:sort(VB).

% @doc Possibly shrink the size of a vclock, depending on current age and size.
-spec prune(V::vclock(), Now::integer(), BucketProps::term()) -> vclock().
Expand Down

0 comments on commit 265a185

Please sign in to comment.