Skip to content

Commit bff7c96

Browse files
committed
Issue #14687: Optimize str%tuple for the "%(name)s" syntax
Avoid an useless and expensive call to PyUnicode_READ().
1 parent 598b2f6 commit bff7c96

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Objects/unicodeobject.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13737,9 +13737,10 @@ PyUnicode_Format(PyObject *format, PyObject *args)
1373713737
keystart = fmtpos;
1373813738
/* Skip over balanced parentheses */
1373913739
while (pcount > 0 && --fmtcnt >= 0) {
13740-
if (PyUnicode_READ(fmtkind, fmt, fmtpos) == ')')
13740+
c = PyUnicode_READ(fmtkind, fmt, fmtpos);
13741+
if (c == ')')
1374113742
--pcount;
13742-
else if (PyUnicode_READ(fmtkind, fmt, fmtpos) == '(')
13743+
else if (c == '(')
1374313744
++pcount;
1374413745
fmtpos++;
1374513746
}

0 commit comments

Comments
 (0)