[pypy-commit] pypy default: move computation of flattened marks into its own function since it only needs
cfbolz
noreply at buildbot.pypy.org
Thu Nov 6 13:21:42 CET 2014
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch:
Changeset: r74353:bc52afdac223
Date: 2014-11-06 13:17 +0100
http://bitbucket.org/pypy/pypy/changeset/bc52afdac223/
Log: move computation of flattened marks into its own function since it
only needs to be run once
diff --git a/rpython/rlib/rsre/rsre_core.py b/rpython/rlib/rsre/rsre_core.py
--- a/rpython/rlib/rsre/rsre_core.py
+++ b/rpython/rlib/rsre/rsre_core.py
@@ -137,22 +137,25 @@
def flatten_marks(self):
# for testing
if self.match_marks_flat is None:
- self.match_marks_flat = [self.match_start, self.match_end]
- mark = self.match_marks
- if mark is not None:
- self.match_lastindex = mark.gid
- else:
- self.match_lastindex = -1
- while mark is not None:
- index = mark.gid + 2
- while index >= len(self.match_marks_flat):
- self.match_marks_flat.append(-1)
- if self.match_marks_flat[index] == -1:
- self.match_marks_flat[index] = mark.position
- mark = mark.prev
- self.match_marks = None # clear
+ self._compute_flattened_marks()
return self.match_marks_flat
+ def _compute_flattened_marks(self):
+ self.match_marks_flat = [self.match_start, self.match_end]
+ mark = self.match_marks
+ if mark is not None:
+ self.match_lastindex = mark.gid
+ else:
+ self.match_lastindex = -1
+ while mark is not None:
+ index = mark.gid + 2
+ while index >= len(self.match_marks_flat):
+ self.match_marks_flat.append(-1)
+ if self.match_marks_flat[index] == -1:
+ self.match_marks_flat[index] = mark.position
+ mark = mark.prev
+ self.match_marks = None # clear
+
def span(self, groupnum=0):
# compatibility
fmarks = self.flatten_marks()
More information about the pypy-commit
mailing list