summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Newson <rnewson@apache.org>2021-02-27 09:51:12 +0000
committerRobert Newson <rnewson@apache.org>2021-02-27 09:51:12 +0000
commit45d4039dbe2cbefe92d13105542596690d05b3be (patch)
treea1bfcda2a166e26ba920a42ae35be8467db5845b
parent3d4a827bda9ae60cf8d223e3d213c1852b32b4f1 (diff)
downloadcouchdb-45d4039dbe2cbefe92d13105542596690d05b3be.tar.gz
Optimize lookup/3ebtree-lookup-opt
A tidier version of https://github.com/apache/couchdb/pull/3384 that saves an unnecessary call to collate.
-rw-r--r--src/ebtree/src/ebtree.erl8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/ebtree/src/ebtree.erl b/src/ebtree/src/ebtree.erl
index 8962b1502..a62074ca0 100644
--- a/src/ebtree/src/ebtree.erl
+++ b/src/ebtree/src/ebtree.erl
@@ -133,12 +133,12 @@ max() ->
lookup(Db, #tree{} = Tree, Key) ->
Fun = fun
({visit, K, V}, Acc) ->
- case {collate(Tree, K, Key, [eq]), collate(Tree, K, Key, [gt])} of
- {true, _} ->
+ case collate(Tree, K, Key) of
+ eq ->
{stop, {K, V}};
- {false, true} ->
+ gt ->
{stop, Acc};
- {false, false} ->
+ lt ->
{ok, Acc}
end;
({traverse, F, L, _R}, Acc) ->