store: keep an accumulated length for the shorted dirs in _hybridencode
so we don't have to repeatedly do '/'.join(sdirs) inside the loop
--- a/mercurial/store.py Sun Sep 16 11:35:55 2012 +0200
+++ b/mercurial/store.py Sun Sep 16 11:36:00 2012 +0200
@@ -204,15 +204,20 @@
basename = parts[-1]
_root, ext = os.path.splitext(basename)
sdirs = []
+ sdirslen = 0
for p in parts[:-1]:
d = p[:_dirprefixlen]
if d[-1] in '. ':
# Windows can't access dirs ending in period or space
d = d[:-1] + '_'
- t = '/'.join(sdirs) + '/' + d
- if len(t) > _maxshortdirslen:
- break
+ if sdirslen == 0:
+ t = len(d)
+ else:
+ t = sdirslen + 1 + len(d)
+ if t > _maxshortdirslen:
+ break
sdirs.append(d)
+ sdirslen = t
dirs = '/'.join(sdirs)
if len(dirs) > 0:
dirs += '/'