##// END OF EJS Templates
dirstate: speed up sorting in findfiles
Matt Mackall -
r5002:4d079df2 default
parent child Browse files
Show More
@@ -379,8 +379,11 b' class dirstate(object):'
379 # recursion free walker, faster than os.walk.
379 # recursion free walker, faster than os.walk.
380 def findfiles(s):
380 def findfiles(s):
381 work = [s]
381 work = [s]
382 wadd = work.append
383 found = []
384 add = found.append
382 if directories:
385 if directories:
383 yield 'd', normpath(s[common_prefix_len:]), lstat(s)
386 add((normpath(s[common_prefix_len:]), 'd', lstat(s)))
384 while work:
387 while work:
385 top = work.pop()
388 top = work.pop()
386 names = listdir(top)
389 names = listdir(top)
@@ -407,16 +410,18 b' class dirstate(object):'
407 st = lstat(p)
410 st = lstat(p)
408 if s_isdir(st.st_mode):
411 if s_isdir(st.st_mode):
409 if not ignore(np):
412 if not ignore(np):
410 work.append(p)
413 wadd(p)
411 if directories:
414 if directories:
412 yield 'd', np, st
415 add((np, 'd', st))
413 if np in dc and match(np):
416 if np in dc and match(np):
414 yield 'm', np, st
417 add((np, 'm', st))
415 elif imatch(np):
418 elif imatch(np):
416 if supported(np, st.st_mode):
419 if supported(np, st.st_mode):
417 yield 'f', np, st
420 add((np, 'f', st))
418 elif np in dc:
421 elif np in dc:
419 yield 'm', np, st
422 add((np, 'm', st))
423 found.sort()
424 return found
420
425
421 # step one, find all files that match our criteria
426 # step one, find all files that match our criteria
422 files.sort()
427 files.sort()
@@ -439,11 +444,8 b' class dirstate(object):'
439 yield 'b', ff, None
444 yield 'b', ff, None
440 continue
445 continue
441 if s_isdir(st.st_mode):
446 if s_isdir(st.st_mode):
442 cmp1 = (lambda x, y: cmp(x[1], y[1]))
447 for f, src, st in findfiles(f):
443 sorted_ = [ x for x in findfiles(f) ]
448 yield src, f, st
444 sorted_.sort(cmp1)
445 for e in sorted_:
446 yield e
447 else:
449 else:
448 if nf in known:
450 if nf in known:
449 continue
451 continue
General Comments 0
You need to be logged in to leave comments. Login now