You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2022/06/11 17:09:12 UTC

[GitHub] [couchdb] nickva commented on a diff in pull request #4059: Reduce complexity of "possible_ancestors" from quadratic to linear.

nickva commented on code in PR #4059:
URL: https://github.com/apache/couchdb/pull/4059#discussion_r895047297


##########
src/couch/src/couch_db.erl:
##########
@@ -2102,28 +2102,12 @@ possible_ancestors(_FullInfo, []) ->
 possible_ancestors(FullInfo, MissingRevs) ->
     #doc_info{revs = RevsInfo} = couch_doc:to_doc_info(FullInfo),
     LeafRevs = [Rev || #rev_info{rev = Rev} <- RevsInfo],
-    % Find the revs that are possible parents of this rev
-    lists:foldl(
-        fun({LeafPos, LeafRevId}, Acc) ->
-            % this leaf is a "possible ancenstor" of the missing
-            % revs if this LeafPos lessthan any of the missing revs
-            case
-                lists:any(
-                    fun({MissingPos, _}) ->
-                        LeafPos < MissingPos
-                    end,
-                    MissingRevs
-                )
-            of
-                true ->
-                    [{LeafPos, LeafRevId} | Acc];
-                false ->
-                    Acc
-            end
-        end,
-        [],
-        LeafRevs
-    ).
+    % Find the revs that are possible parents of this rev. A leaf is a possible
+    % ancestor if the leaf position is less than any of the missing revs, and
+    % if it's less than the any, it means it's also less than the maximum

Review Comment:
   Definitely a typo. Will fix it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org