Issue #14687: Optimize str%tuple for the "%(name)s" syntax

Avoid an useless and expensive call to PyUnicode_READ().
This commit is contained in:
Victor Stinner 2012-05-03 01:44:59 +02:00
parent 598b2f6bd0
commit bff7c96834
1 changed files with 3 additions and 2 deletions

View File

@ -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++;
}