[pypy-commit] pypy default: call prev_codepoint_pos only once
cfbolz
pypy.commits at gmail.com
Mon Sep 16 04:52:30 EDT 2019
Author: Carl Friedrich Bolz-Tereick <cfbolz at gmx.de>
Branch:
Changeset: r97487:6e05da20e7bd
Date: 2019-09-16 10:51 +0200
http://bitbucket.org/pypy/pypy/changeset/6e05da20e7bd/
Log: call prev_codepoint_pos only once
diff --git a/pypy/objspace/std/unicodeobject.py b/pypy/objspace/std/unicodeobject.py
--- a/pypy/objspace/std/unicodeobject.py
+++ b/pypy/objspace/std/unicodeobject.py
@@ -1085,9 +1085,11 @@
lgt -= 1
if right:
- while rpos > lpos and rutf8.isspace(value,
- rutf8.prev_codepoint_pos(value, rpos)):
- rpos = rutf8.prev_codepoint_pos(value, rpos)
+ while rpos > lpos:
+ prev = rutf8.prev_codepoint_pos(value, rpos)
+ if not rutf8.isspace(value, prev):
+ break
+ rpos = prev
lgt -= 1
assert rpos >= lpos # annotator hint, don't remove
@@ -1108,9 +1110,11 @@
lgt -= 1
if right:
- while rpos > lpos and rutf8.utf8_in_chars(value,
- rutf8.prev_codepoint_pos(value, rpos), chars):
- rpos = rutf8.prev_codepoint_pos(value, rpos)
+ while rpos > lpos:
+ prev = rutf8.prev_codepoint_pos(value, rpos)
+ if not rutf8.utf8_in_chars(value, prev, chars):
+ break
+ rpos = prev
lgt -= 1
assert rpos >= lpos # annotator hint, don't remove
More information about the pypy-commit
mailing list