Permalink
Browse files

vclock:equal/2: Much simpler, much faster (25x).

  • Loading branch information...
1 parent 945fd24 commit 265a185a255dbf02327db9dba0a5a2b4c1e8c6d4 @esstrifork esstrifork committed Jul 8, 2011
Showing with 1 addition and 11 deletions.
  1. +1 −11 src/vclock.erl
View
@@ -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().

0 comments on commit 265a185

Please sign in to comment.