Author: fijal Branch: unicode-utf8 Changeset: r93293:8c2d7104d91e Date: 2017-12-07 14:36 +0200 http://bitbucket.org/pypy/pypy/changeset/8c2d7104d91e/
Log: use iterator and add some more obscure iterface for it diff --git a/rpython/rlib/rutf8.py b/rpython/rlib/rutf8.py --- a/rpython/rlib/rutf8.py +++ b/rpython/rlib/rutf8.py @@ -770,6 +770,12 @@ def __iter__(self): return self + def get_pos(self): + return self._pos + + def done(self): + return self._pos == self._end + @always_inline def next(self): pos = self._pos diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py --- a/rpython/rtyper/lltypesystem/rffi.py +++ b/rpython/rtyper/lltypesystem/rffi.py @@ -1025,11 +1025,9 @@ from rpython.rlib import rutf8 w = lltype.malloc(CWCHARP.TO, utf8len + 1, flavor='raw') - i = 0 index = 0 - while i < len(utf8): - w[index] = unichr(rutf8.codepoint_at_pos(utf8, i)) - i = rutf8.next_codepoint_pos(utf8, i) + for ch in rutf8.Utf8StringIterator(utf8): + w[index] = unichr(ch) index += 1 w[index] = unichr(0) return w _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit