##// END OF EJS Templates
store: optimize _auxencode() by assigning to the list elements of the path
Adrian Buehlmann -
r17571:7ed972a9 default
parent child Browse files
Show More
@@ -141,11 +141,12 b' def _auxencode(path, dotencode):'
141 >>> _auxencode(' .foo', True)
141 >>> _auxencode(' .foo', True)
142 '~20.foo'
142 '~20.foo'
143 '''
143 '''
144 res = []
144 res = path.split('/')
145 for n in path.split('/'):
145 for i, n in enumerate(res):
146 if n:
146 if n:
147 if dotencode and n[0] in '. ':
147 if dotencode and n[0] in '. ':
148 n = "~%02x" % ord(n[0]) + n[1:]
148 n = "~%02x" % ord(n[0]) + n[1:]
149 res[i] = n
149 else:
150 else:
150 l = n.find('.')
151 l = n.find('.')
151 if l == -1:
152 if l == -1:
@@ -156,10 +157,11 b' def _auxencode(path, dotencode):'
156 # encode third letter ('aux' -> 'au~78')
157 # encode third letter ('aux' -> 'au~78')
157 ec = "~%02x" % ord(n[2])
158 ec = "~%02x" % ord(n[2])
158 n = n[0:2] + ec + n[3:]
159 n = n[0:2] + ec + n[3:]
160 res[i] = n
159 if n[-1] in '. ':
161 if n[-1] in '. ':
160 # encode last period or space ('foo...' -> 'foo..~2e')
162 # encode last period or space ('foo...' -> 'foo..~2e')
161 n = n[:-1] + "~%02x" % ord(n[-1])
163 n = n[:-1] + "~%02x" % ord(n[-1])
162 res.append(n)
164 res[i] = n
163 return '/'.join(res)
165 return '/'.join(res)
164
166
165 _maxstorepathlen = 120
167 _maxstorepathlen = 120
General Comments 0
You need to be logged in to leave comments. Login now