Mercurial > hg-stable
changeset 17588:3d789dd72316
store: keep an accumulated length for the shorted dirs in _hybridencode
so we don't have to repeatedly do '/'.join(sdirs) inside the loop
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Sun, 16 Sep 2012 11:36:00 +0200 |
parents | 5fb8cf6f4f58 |
children | b11024849db6 |
files | mercurial/store.py |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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 += '/'