# Pastebin 1aGawBTa diff -r 5b81f483c459 pypy/objspace/std/unicodeobject.py --- a/pypy/objspace/std/unicodeobject.py Fri Nov 24 15:14:15 2017 +0100 +++ b/pypy/objspace/std/unicodeobject.py Fri Nov 24 15:20:51 2017 +0100 @@ -369,22 +369,16 @@ @jit.elidable def title_unicode(self, value): input = self._utf8 - builder = StringBuilder(len(input)) - i = 0 + builder = rutf8.Utf8StringBuilder(len(input)) previous_is_cased = False - flag = self._get_flag() - while i < len(input): - ch = rutf8.codepoint_at_pos(input, i) - i = rutf8.next_codepoint_pos(input, i) + for ch in rutf8.Utf8StringIterator(input): if not previous_is_cased: ch = unicodedb.totitle(ch) else: ch = unicodedb.tolower(ch) - if ch >= 0x80: - flag = rutf8.combine_flags(flag, rutf8.FLAG_REGULAR) - rutf8.unichr_as_utf8_append(builder, ch, allow_surrogates=True) + builder.append_code(ch) previous_is_cased = unicodedb.iscased(ch) - return builder.build(), flag + return builder.build(), builder.get_flag() def descr_translate(self, space, w_table): input = self._utf8