Commit bff7c968 authored by Victor Stinner's avatar Victor Stinner

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

Avoid an useless and expensive call to PyUnicode_READ().
parent 598b2f6b
...@@ -13737,9 +13737,10 @@ PyUnicode_Format(PyObject *format, PyObject *args) ...@@ -13737,9 +13737,10 @@ PyUnicode_Format(PyObject *format, PyObject *args)
keystart = fmtpos; keystart = fmtpos;
/* Skip over balanced parentheses */ /* Skip over balanced parentheses */
while (pcount > 0 && --fmtcnt >= 0) { while (pcount > 0 && --fmtcnt >= 0) {
if (PyUnicode_READ(fmtkind, fmt, fmtpos) == ')') c = PyUnicode_READ(fmtkind, fmt, fmtpos);
if (c == ')')
--pcount; --pcount;
else if (PyUnicode_READ(fmtkind, fmt, fmtpos) == '(') else if (c == '(')
++pcount; ++pcount;
fmtpos++; fmtpos++;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment