##// END OF EJS Templates
match: optimize escaping in _globre...
Matt Mackall -
r8583:19d1b2ae default
parent child Browse files
Show More
@@ -125,11 +125,14 b' def _globre(pat):'
125 i, n = 0, len(pat)
125 i, n = 0, len(pat)
126 res = ''
126 res = ''
127 group = 0
127 group = 0
128 escape = re.escape
128 def peek(): return i < n and pat[i]
129 def peek(): return i < n and pat[i]
129 while i < n:
130 while i < n:
130 c = pat[i]
131 c = pat[i]
131 i = i+1
132 i = i+1
132 if c == '*':
133 if c not in '*?[{},\\':
134 res += escape(c)
135 elif c == '*':
133 if peek() == '*':
136 if peek() == '*':
134 i += 1
137 i += 1
135 res += '.*'
138 res += '.*'
@@ -165,11 +168,11 b' def _globre(pat):'
165 p = peek()
168 p = peek()
166 if p:
169 if p:
167 i += 1
170 i += 1
168 res += re.escape(p)
171 res += escape(p)
169 else:
172 else:
170 res += re.escape(c)
173 res += escape(c)
171 else:
174 else:
172 res += re.escape(c)
175 res += escape(c)
173 return res
176 return res
174
177
175 def _regex(kind, name, tail):
178 def _regex(kind, name, tail):
General Comments 0
You need to be logged in to leave comments. Login now