[pypy-commit] pypy lstrip_to_empty_string: If possible, make lstrip consume the whole string.
Nate Bragg
pypy.commits at gmail.com
Tue Mar 28 07:26:26 EDT 2017
Author: Nate Bragg <nate at cs.tufts.edu>
Branch: lstrip_to_empty_string
Changeset: r90834:2275619cea33
Date: 2017-03-28 07:10 -0400
http://bitbucket.org/pypy/pypy/changeset/2275619cea33/
Log: If possible, make lstrip consume the whole string.
Previously, it would not consume the final character even if it
matched, because rpos pointed to the final index.
diff --git a/rpython/rtyper/lltypesystem/rstr.py b/rpython/rtyper/lltypesystem/rstr.py
--- a/rpython/rtyper/lltypesystem/rstr.py
+++ b/rpython/rtyper/lltypesystem/rstr.py
@@ -435,7 +435,7 @@
lpos = 0
rpos = s_len - 1
if left:
- while lpos < rpos and s.chars[lpos] == ch:
+ while lpos <= rpos and s.chars[lpos] == ch:
lpos += 1
if right:
while lpos < rpos + 1 and s.chars[rpos] == ch:
@@ -456,7 +456,7 @@
lpos = 0
rpos = s_len - 1
if left:
- while lpos < rpos and s.chars[lpos].isspace():
+ while lpos <= rpos and s.chars[lpos].isspace():
lpos += 1
if right:
while lpos < rpos + 1 and s.chars[rpos].isspace():
@@ -477,7 +477,7 @@
lpos = 0
rpos = s_len - 1
if left:
- while lpos < rpos and LLHelpers.ll_contains(s2, s.chars[lpos]):
+ while lpos <= rpos and LLHelpers.ll_contains(s2, s.chars[lpos]):
lpos += 1
if right:
while lpos < rpos + 1 and LLHelpers.ll_contains(s2, s.chars[rpos]):
More information about the pypy-commit
mailing list