diff mercurial/dirstate.py @ 2671:82864a2eb709

self.root == '/': prefix length computation out of the loop - put the computation out of the loop - change the variable to a more meaningful name
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Tue, 25 Jul 2006 21:22:56 +0200
parents 93eb49419760
children e78cad1f6b1f
line wrap: on
line diff
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -344,19 +344,19 @@ class dirstate(object):
     # directly by this function, but might be modified by your statmatch call.
     #
     def walkhelper(self, files, statmatch, dc, badmatch=None):
+        # self.root may end with a path separator when self.root == '/'
+        common_prefix_len = len(self.root)
+        if not self.root.endswith('/'):
+            common_prefix_len += 1
         # recursion free walker, faster than os.walk.
         def findfiles(s):
             work = [s]
-            # self.root may end with a path separator when self.root == '/'
-            root_subtract_len = len(self.root)
-            if not self.root.endswith('/'):
-                root_subtract_len += 1
             while work:
                 top = work.pop()
                 names = os.listdir(top)
                 names.sort()
                 # nd is the top of the repository dir tree
-                nd = util.normpath(top[root_subtract_len:])
+                nd = util.normpath(top[common_prefix_len:])
                 if nd == '.':
                     nd = ''
                 else: