Patchwork [1,of,3,stable] obsolete: stop doing membership test on list

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 17, 2013, 1:45 a.m.
Message ID <77ec457df3be5d413a14.1384652710@vulgaris>
Download mbox | patch
Permalink /patch/3006/
State Accepted
Commit ba0c4e36da09ac49119d68d349a7d8f6608c3f02
Headers show

Comments

Pierre-Yves David - Nov. 17, 2013, 1:45 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1384652098 18000
#      Sat Nov 16 20:34:58 2013 -0500
# Branch stable
# Node ID 77ec457df3be5d413a14b31c02df2f51628396e2
# Parent  cb466830826a5fb0eecd4428922c2618d6a1b8af
obsolete: stop doing membership test on list

According to the Surgeon General, computer should not use list for membership
testing because of the risk of being slow.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -265,11 +265,12 @@  class obsstore(object):
 
         Take care of filtering duplicate.
         Return the number of new marker."""
         if not _enabled:
             raise util.Abort('obsolete feature is not enabled on this repo')
-        new = [m for m in markers if m not in self._all]
+        known = set(self._all)
+        new = [m for m in markers if m not in known]
         if new:
             f = self.sopener('obsstore', 'ab')
             try:
                 # Whether the file's current position is at the begin or at
                 # the end after opening a file for appending is implementation