From 5b88a71e1de5e50ce7f2cc4e81b86560a0b0fbbd Mon Sep 17 00:00:00 2001 From: Kresten Krab Thorup Date: Sun, 6 May 2012 19:49:53 +0200 Subject: [PATCH] Simplify riak_kv_hanoi_backend:is_empty/1 Do range fold with limit=1, rather than throw exception. --- src/riak_kv_hanoi_backend.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/riak_kv_hanoi_backend.erl b/src/riak_kv_hanoi_backend.erl index 37640d4..080b005 100644 --- a/src/riak_kv_hanoi_backend.erl +++ b/src/riak_kv_hanoi_backend.erl @@ -303,10 +303,10 @@ drop(#state{ tree=Tree, partition=Partition, config=Config }=State) -> %% non-tombstone values; otherwise returns false. -spec is_empty(state()) -> boolean(). is_empty(#state{tree=Tree}) -> - FoldFun = fun(_K, _V, _Acc) -> throw(ok) end, + FoldFun = fun(K, _V, Acc) -> [K|Acc] end, try Range = to_key_range(undefined), - [] =:= hanoi:fold_range(Tree, FoldFun, [], Range) + [] =:= hanoi:fold_range(Tree, FoldFun, [], Range#btree_range{ limit=1 }) catch _:ok -> false