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