changeset 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 118b198c9423 109a22f5434a
files mercurial/dirstate.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Tue Jul 25 11:09:17 2006 -0700
+++ b/mercurial/dirstate.py	Tue Jul 25 21:22:56 2006 +0200
@@ -344,19 +344,19 @@
     # 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: