You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by rnewson <gi...@git.apache.org> on 2016/05/16 10:34:59 UTC

[GitHub] couchdb-couch pull request: Fix couch_key_tree:get_key_leafs/2

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

    https://github.com/apache/couchdb-couch/pull/167#discussion_r63335812
  
    --- 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 --
    
    I'm not clear why you pulled this up when it's only used once. Is this is a tidy only or did you mean to use it at 298?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---