##// END OF EJS Templates
util.fspath: use a dict rather than a linear scan for lookups...
Siddharth Agarwal -
r23097:30124c40 stable
parent child Browse files
Show More
@@ -899,11 +899,8 b' def fspath(name, root):'
899
899
900 The root should be normcase-ed, too.
900 The root should be normcase-ed, too.
901 '''
901 '''
902 def find(p, contents):
902 def _makefspathcacheentry(dir):
903 for n in contents:
903 return dict((normcase(n), n) for n in os.listdir(dir))
904 if normcase(n) == p:
905 return n
906 return None
907
904
908 seps = os.sep
905 seps = os.sep
909 if os.altsep:
906 if os.altsep:
@@ -919,16 +916,15 b' def fspath(name, root):'
919 continue
916 continue
920
917
921 if dir not in _fspathcache:
918 if dir not in _fspathcache:
922 _fspathcache[dir] = os.listdir(dir)
919 _fspathcache[dir] = _makefspathcacheentry(dir)
923 contents = _fspathcache[dir]
920 contents = _fspathcache[dir]
924
921
925 found = find(part, contents)
922 found = contents.get(part)
926 if not found:
923 if not found:
927 # retry "once per directory" per "dirstate.walk" which
924 # retry "once per directory" per "dirstate.walk" which
928 # may take place for each patches of "hg qpush", for example
925 # may take place for each patches of "hg qpush", for example
929 contents = os.listdir(dir)
926 _fspathcache[dir] = contents = _makefspathcacheentry(dir)
930 _fspathcache[dir] = contents
927 found = contents.get(part)
931 found = find(part, contents)
932
928
933 result.append(found or part)
929 result.append(found or part)
934 dir = os.path.join(dir, part)
930 dir = os.path.join(dir, part)
General Comments 0
You need to be logged in to leave comments. Login now