[pypy-commit] pypy default: avoid using range
mattip
pypy.commits at gmail.com
Wed Mar 13 01:26:52 EDT 2019
Author: Matti Picus <matti.picus at gmail.com>
Branch:
Changeset: r96304:ab0f20d4a572
Date: 2019-03-13 07:24 +0200
http://bitbucket.org/pypy/pypy/changeset/ab0f20d4a572/
Log: avoid using range
diff --git a/rpython/rlib/rsre/rsre_utf8.py b/rpython/rlib/rsre/rsre_utf8.py
--- a/rpython/rlib/rsre/rsre_utf8.py
+++ b/rpython/rlib/rsre/rsre_utf8.py
@@ -40,17 +40,23 @@
prev_indirect = prev
def next_n(self, position, n, end_position):
- for i in range(n):
+ i = 0
+ # avoid range(n) since n can be quite large
+ while i < n:
if position >= end_position:
raise EndOfString
position = rutf8.next_codepoint_pos(self._utf8, position)
+ i += 1
return position
def prev_n(self, position, n, start_position):
- for i in range(n):
+ i = 0
+ # avoid range(n) since n can be quite large
+ while i < n:
if position <= start_position:
raise EndOfString
position = rutf8.prev_codepoint_pos(self._utf8, position)
+ i += 1
assert position >= 0
return position
More information about the pypy-commit
mailing list