Author: Carl Friedrich Bolz-Tereick <[email protected]>
Branch:
Changeset: r97414:e32eb9a73d7e
Date: 2019-09-10 11:15 +0200
http://bitbucket.org/pypy/pypy/changeset/e32eb9a73d7e/
Log: two comments
diff --git a/rpython/rlib/rutf8.py b/rpython/rlib/rutf8.py
--- a/rpython/rlib/rutf8.py
+++ b/rpython/rlib/rutf8.py
@@ -486,6 +486,7 @@
length += 1
return length
+
@jit.elidable
def surrogate_in_utf8(value):
"""Check if the UTF-8 byte string 'value' contains a surrogate.
@@ -592,9 +593,12 @@
"""
if bytepos < 0:
return bytepos
+ # binary search on elements of storage
index_min = 0
index_max = len(storage) - 1
while index_min < index_max:
+ # this addition can't overflow because storage has a length that is
+ # 1/64 of the length of a string
index_middle = (index_min + index_max + 1) // 2
base_bytepos = storage[index_middle].baseindex
if bytepos < base_bytepos:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit