changeset 649:a7e267222864

Experimental ignore regex speed-up -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Experimental ignore regex speed-up manifest hash: c6922086fb78201b60ba8cbde5b51512225ebcc8 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCzWkvywK+sNU5EO8RAohzAJ9BwkFJQzs0QRH71r1Y1Wm0QCSmEwCgrESQ Ej3Kt/y0JdhOJzQLsAiufqk= =SPjY -----END PGP SIGNATURE-----
author Matt Mackall <mpm@selenic.com>
date Thu, 07 Jul 2005 09:41:03 -0800
parents 8c89408a7154
children 2c934c7b79dc
files mercurial/hg.py
diffstat 1 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hg.py	Wed Jul 06 22:41:56 2005 -0800
+++ b/mercurial/hg.py	Thu Jul 07 09:41:03 2005 -0800
@@ -487,7 +487,7 @@
         self.wopener = opener(self.root)
         self.manifest = manifest(self.opener)
         self.changelog = changelog(self.opener)
-        self.ignorelist = None
+        self.ignorefunc = None
         self.tagscache = None
         self.nodetagscache = None
 
@@ -498,17 +498,22 @@
             except IOError: pass
 
     def ignore(self, f):
-        if self.ignorelist is None:
-            self.ignorelist = []
+        if not self.ignorefunc:
+            bigpat = []
             try:
                 l = file(self.wjoin(".hgignore"))
                 for pat in l:
                     if pat != "\n":
-                        self.ignorelist.append(re.compile(util.pconvert(pat[:-1])))
+                        bigpat.append(util.pconvert(pat[:-1]))
             except IOError: pass
-        for pat in self.ignorelist:
-            if pat.search(f): return True
-        return False
+            if bigpat:
+                s = "(%s)" % (")|(".join(bigpat))
+                r = re.compile(s)
+                self.ignorefunc = r.search
+            else:
+                self.ignorefunc = lambda x: False
+
+        return self.ignorefunc(f)
 
     def hook(self, name, **args):
         s = self.ui.config("hooks", name)