diff options
author | Robert Newson <rnewson@apache.org> | 2021-02-28 17:48:10 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-28 17:48:10 +0000 |
commit | a9e0ebe2434e4bcdc7fe156e888767e7e57c26ec (patch) | |
tree | a1bfcda2a166e26ba920a42ae35be8467db5845b | |
parent | 3d4a827bda9ae60cf8d223e3d213c1852b32b4f1 (diff) | |
parent | 45d4039dbe2cbefe92d13105542596690d05b3be (diff) | |
download | couchdb-a9e0ebe2434e4bcdc7fe156e888767e7e57c26ec.tar.gz |
Merge pull request #3386 from apache/ebtree-lookup-opt
Optimize lookup/3
-rw-r--r-- | src/ebtree/src/ebtree.erl | 8 |
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) -> |