diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2012-05-02 23:44:59 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2012-05-02 23:44:59 (GMT) |
commit | bff7c9683442a6297bda2fb1ebedf73c9e4a265f (patch) | |
tree | 8d135d9c8d0d550bd16c884427e0fbec65a8ca2c /Objects | |
parent | 598b2f6bd02b1aa118263538fa9e33769da553df (diff) | |
download | cpython-bff7c9683442a6297bda2fb1ebedf73c9e4a265f.zip cpython-bff7c9683442a6297bda2fb1ebedf73c9e4a265f.tar.gz cpython-bff7c9683442a6297bda2fb1ebedf73c9e4a265f.tar.bz2 |
Issue #14687: Optimize str%tuple for the "%(name)s" syntax
Avoid an useless and expensive call to PyUnicode_READ().
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index cf0bab9..e22fcfd 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++; } |