cpython: 08b54c635586 (original) (raw)
Mercurial > cpython
changeset 76658:08b54c635586
Issue #14687: Avoid an useless duplicated string in PyUnicode_Format() [#14687]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Mon, 30 Apr 2012 05:21:52 +0200 |
parents | 42fbb4f9b540 |
children | 7319430a291d |
files | Objects/unicodeobject.c |
diffstat | 1 files changed, 8 insertions(+), 12 deletions(-)[+] [-] Objects/unicodeobject.c 20 |
line wrap: on
line diff
--- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -14051,20 +14051,16 @@ PyUnicode_Format(PyObject format, PyObj } } / Copy all characters, preserving len */
if (temp != NULL) {[](#l1.7)
assert(pbuf == PyUnicode_DATA(temp));[](#l1.8)
v = PyUnicode_Substring(temp, pindex, pindex + len);[](#l1.9)
if (pindex == 0 && len == PyUnicode_GET_LENGTH(temp)) {[](#l1.10)
r = _PyAccu_Accumulate(&acc, temp);[](#l1.11) }[](#l1.12) else {[](#l1.13)
const char *p = (const char *) pbuf;[](#l1.14)
assert(pbuf != NULL);[](#l1.15)
p += kind * pindex;[](#l1.16)
v = PyUnicode_FromKindAndData(kind, p, len);[](#l1.17)
}[](#l1.18)
if (v == NULL)[](#l1.19)
goto onError;[](#l1.20)
r = _PyAccu_Accumulate(&acc, v);[](#l1.21)
Py_DECREF(v);[](#l1.22)
v = PyUnicode_Substring(temp, pindex, pindex + len);[](#l1.23)
if (v == NULL)[](#l1.24)
goto onError;[](#l1.25)
r = _PyAccu_Accumulate(&acc, v);[](#l1.26)
Py_DECREF(v);[](#l1.27)
}[](#l1.28) if (r)[](#l1.29) goto onError;[](#l1.30) if (width > len && repeat_accumulate(&acc, blank, width - len))[](#l1.31)