[Python-checkins] cpython: Issue #14687: Optimize str%tuple for the "%(name)s" syntax

victor.stinner python-checkins at python.org
Thu May 3 01:46:27 CEST 2012


http://hg.python.org/cpython/rev/90b4c2d7c90d
changeset: 76721:90b4c2d7c90d
user: Victor Stinner <victor.stinner at gmail.com>
date: Thu May 03 01:44:59 2012 +0200
summary:
 Issue #14687: Optimize str%tuple for the "%(name)s" syntax
Avoid an useless and expensive call to PyUnicode_READ().
files:
 Objects/unicodeobject.c | 5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -13737,9 +13737,10 @@
 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++;
 }
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /