From: Victor Stinner Date: Wed, 2 May 2012 23:44:59 +0000 (+0200) Subject: Issue #14687: Optimize str%tuple for the "%(name)s" syntax X-Git-Tag: v3.3.0a4~310 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bff7c9683442a6297bda2fb1ebedf73c9e4a265f;p=thirdparty%2FPython%2Fcpython.git Issue #14687: Optimize str%tuple for the "%(name)s" syntax Avoid an useless and expensive call to PyUnicode_READ(). --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index cf0bab9462ca..e22fcfd02b12 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -13737,9 +13737,10 @@ PyUnicode_Format(PyObject *format, PyObject *args) keystart = fmtpos; /* Skip over balanced parentheses */ while (pcount > 0 && --fmtcnt >= 0) { - if (PyUnicode_READ(fmtkind, fmt, fmtpos) == ')') + c = PyUnicode_READ(fmtkind, fmt, fmtpos); + if (c == ')') --pcount; - else if (PyUnicode_READ(fmtkind, fmt, fmtpos) == '(') + else if (c == '(') ++pcount; fmtpos++; }