Bug 899858 - Cache pymake len() computation to speed up parsing. r=benjamin
authorBenoit Girard <b56girard@gmail.com>
Tue, 06 Aug 2013 16:04:47 -0400
changeset 347 cd96f5cee068
parent 346 1cf15f6116e8
child 348 e43aa1231778
push id220
push userb56girard@gmail.com
push dateTue, 06 Aug 2013 20:05:11 +0000
reviewersbenjamin
bugs899858
Bug 899858 - Cache pymake len() computation to speed up parsing. r=benjamin
pymake/data.py
--- a/pymake/data.py
+++ b/pymake/data.py
@@ -568,17 +568,18 @@ class Pattern(object):
     This insane behavior probably doesn't matter, but we're compatible just for shits and giggles.
     """
 
     __slots__ = ('data')
 
     def __init__(self, s):
         r = []
         i = 0
-        while i < len(s):
+        slen = len(s)
+        while i < slen:
             c = s[i]
             if c == '\\':
                 nc = s[i + 1]
                 if nc == '%':
                     r.append('%')
                     i += 1
                 elif nc == '\\':
                     r.append('\\')