Mercurial > hg-stable
changeset 17571:7ed972a9e7a9
store: optimize _auxencode() by assigning to the list elements of the path
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Sat, 15 Sep 2012 21:42:43 +0200 |
parents | f53a7b256ca6 |
children | b644287e79a8 |
files | mercurial/store.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/store.py Sat Sep 15 21:41:09 2012 +0200 +++ b/mercurial/store.py Sat Sep 15 21:42:43 2012 +0200 @@ -141,11 +141,12 @@ >>> _auxencode(' .foo', True) '~20.foo' ''' - res = [] - for n in path.split('/'): + res = path.split('/') + for i, n in enumerate(res): if n: if dotencode and n[0] in '. ': n = "~%02x" % ord(n[0]) + n[1:] + res[i] = n else: l = n.find('.') if l == -1: @@ -156,10 +157,11 @@ # encode third letter ('aux' -> 'au~78') ec = "~%02x" % ord(n[2]) n = n[0:2] + ec + n[3:] + res[i] = n if n[-1] in '. ': # encode last period or space ('foo...' -> 'foo..~2e') n = n[:-1] + "~%02x" % ord(n[-1]) - res.append(n) + res[i] = n return '/'.join(res) _maxstorepathlen = 120