self.root == '/': prefix length computation out of the loop
- put the computation out of the loop
- change the variable to a more meaningful name
--- 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: