Author: Armin Rigo <ar...@tunes.org> Branch: py3.5 Changeset: r88640:85f1c9ac66f6 Date: 2016-11-24 15:09 +0100 http://bitbucket.org/pypy/pypy/changeset/85f1c9ac66f6/
Log: Use conditional_call_value 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 @@ -79,14 +79,9 @@ def identifier_w(self, space): try: - if jit.isconstant(self._value): - # constantly encode that unicode string; don't try - # to access the cache _utf8 at all - identifier = self._value.encode('utf-8') - else: - # call the elidable function, with a jit.call_shortcut in case - # self._utf8 is already computed - identifier = g_identifier_w(self, space) + identifier = jit.conditional_call_elidable( + self._utf8, g_encode_utf8, self._value) + self._utf8 = identifier except UnicodeEncodeError: # bah, this is just to get an official app-level # UnicodeEncodeError @@ -1278,15 +1273,9 @@ allow_surrogates=allow_surrogates) @jit.elidable -@jit.call_shortcut -def g_identifier_w(self, space): - """This is a global function because of @jit.call_shortcut""" - identifier = self._utf8 - if identifier is not None: - return identifier - identifier = self._value.encode('utf-8') - self._utf8 = identifier - return identifier +def g_encode_utf8(value): + """This is a global function because of jit.conditional_call_value""" + return value.encode('utf-8') _repr_function, _ = make_unicode_escape_function( pass_printable=True, unicode_output=True, quotes=True, prefix='') _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit