diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-04-09 20:52:48 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-04-09 20:52:48 (GMT) |
commit | 0cff4b16d922ad140991bf469cc944ad4858ed49 (patch) | |
tree | 78fe768c5bcc7f40c2e8332179a4a65d94dbba4e /Objects | |
parent | cc7af7219217f247775b9079f75713399f2f0f28 (diff) | |
download | cpython-0cff4b16d922ad140991bf469cc944ad4858ed49.zip cpython-0cff4b16d922ad140991bf469cc944ad4858ed49.tar.gz cpython-0cff4b16d922ad140991bf469cc944ad4858ed49.tar.bz2 |
replace(): only call PyUnicode_DATA(u) once
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index e348a46..6b63157 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -9972,7 +9972,7 @@ replace(PyObject *self, PyObject *str1, Py_UCS4 u1, u2; int rkind; Py_ssize_t index, pos; - char *src; + char *src, *rbuf; u1 = PyUnicode_READ(kind1, buf1, 0); pos = findchar(sbuf, PyUnicode_KIND(self), slen, u1, 1); @@ -9984,8 +9984,9 @@ replace(PyObject *self, PyObject *str1, goto error; _PyUnicode_FastCopyCharacters(u, 0, self, 0, slen); rkind = PyUnicode_KIND(u); + rbuf = PyUnicode_DATA(u); - PyUnicode_WRITE(rkind, PyUnicode_DATA(u), pos, u2); + PyUnicode_WRITE(rkind, rbuf, pos, u2); index = 0; src = sbuf; while (--maxcount) @@ -9997,7 +9998,7 @@ replace(PyObject *self, PyObject *str1, pos = findchar(src, PyUnicode_KIND(self), slen, u1, 1); if (pos < 0) break; - PyUnicode_WRITE(rkind, PyUnicode_DATA(u), index + pos, u2); + PyUnicode_WRITE(rkind, rbuf, index + pos, u2); } } else { |