diff Objects/unicodeobject.c @ 76721:90b4c2d7c90d

Issue #14687: Optimize str%tuple for the "%(name)s" syntax Avoid an useless and expensive call to PyUnicode_READ().
author Victor Stinner <victor.stinner@gmail.com>
date Thu, 03 May 2012 01:44:59 +0200
parents 359b1a6a3836
children 3d83e2297166
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Wed May 02 20:51:59 2012 +0200
+++ b/Objects/unicodeobject.c	Thu May 03 01:44:59 2012 +0200
@@ -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++;
                 }