Github user davisp commented on a diff in the pull request:

    https://github.com/apache/couchdb-couch/pull/167#discussion_r63379218
  
    --- Diff: src/couch_key_tree.erl ---
    @@ -280,25 +280,41 @@ get_key_leafs([{Pos, Tree}|Rest], Keys, Acc) ->
         {Gotten, RemainingKeys} = get_key_leafs_simple(Pos, [Tree], Keys, []),
         get_key_leafs(Rest, RemainingKeys, Gotten ++ Acc).
     
    -get_key_leafs_simple(_Pos, _Tree, [], _KeyPathAcc) ->
    +get_key_leafs_simple(_Pos, _Tree, [], _PathAcc) ->
         {[], []};
    -get_key_leafs_simple(_Pos, [], KeysToGet, _KeyPathAcc) ->
    -    {[], KeysToGet};
    -get_key_leafs_simple(Pos, [{Key, _Value, SubTree}=Tree | RestTree], 
KeysToGet, KeyPathAcc) ->
    -    case lists:delete({Pos, Key}, KeysToGet) of
    -    KeysToGet -> % same list, key not found
    -        {LeafsFound, KeysToGet2} = get_key_leafs_simple(Pos + 1, SubTree, 
KeysToGet, [Key | KeyPathAcc]),
    -        {RestLeafsFound, KeysRemaining} = get_key_leafs_simple(Pos, 
RestTree, KeysToGet2, KeyPathAcc),
    -        {LeafsFound ++ RestLeafsFound, KeysRemaining};
    -    KeysToGet2 ->
    -        LeafsFound = get_all_leafs_simple(Pos, [Tree], KeyPathAcc),
    -        LeafKeysFound = [{LeafPos, LeafRev} || {_, {LeafPos, [LeafRev|_]}}
    -            <- LeafsFound],
    -        KeysToGet3 = KeysToGet2 -- LeafKeysFound,
    -        {RestLeafsFound, KeysRemaining} = get_key_leafs_simple(Pos, 
RestTree, KeysToGet3, KeyPathAcc),
    -        {LeafsFound ++ RestLeafsFound, KeysRemaining}
    +get_key_leafs_simple(_Pos, [], Keys, _PathAcc) ->
    +    {[], Keys};
    +get_key_leafs_simple(Pos, [{Key, _, SubTree}=Tree | RestTree], Keys, 
PathAcc) ->
    +    NewPathAcc = [Key | PathAcc],
    --- End diff --
    
    Good catch. That should be moved down into the first clause. It was just a 
tidy for line length. I'm also going to add a couple comments to 
get_key_leafs_simple2 because that took me entirely too long to page back in.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to