couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [couchdb] 01/01: use collate in lookup
Date Fri, 26 Feb 2021 19:10:37 GMT
This is an automated email from the ASF dual-hosted git repository.

rnewson pushed a commit to branch ebtree-lookup-collate-eq
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 6f6db1ee27d8ac2879b4149378ea6b94dc5ddc42
Author: Robert Newson <rnewson@apache.org>
AuthorDate: Fri Feb 26 19:05:05 2021 +0000

    use collate in lookup
---
 src/ebtree/src/ebtree.erl | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/ebtree/src/ebtree.erl b/src/ebtree/src/ebtree.erl
index 1a65c9a..1aa1494 100644
--- a/src/ebtree/src/ebtree.erl
+++ b/src/ebtree/src/ebtree.erl
@@ -132,13 +132,13 @@ max() ->
     {Key :: term(), Value :: term()} | false.
 lookup(Db, #tree{} = Tree, Key) ->
     Fun = fun
-        ({visit, K, V}, _Acc) when K =:= Key ->
-            {stop, {K, V}};
-        ({visit, K, _V}, Acc) ->
-            case collate(Tree, K, Key, [gt]) of
-                true ->
+        ({visit, K, V}, Acc) ->
+            case {collate(Tree, K, Key, [eq]), collate(Tree, K, Key, [gt])} of
+                {true, _} ->
+                    {stop, {K, V}};
+                {false, true} ->
                     {stop, Acc};
-                false ->
+                {false, false} ->
                     {ok, Acc}
             end;
         ({traverse, F, L, _R}, Acc) ->


Mime
View raw message