summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2006-05-22 16:29:30 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2006-05-22 16:29:30 (GMT)
commitf1d60a53845d2efeccdb61bebf6ee8df94df16d4 (patch)
treee94e4f8352ee740ad313550f1a3b7863c28c441c /Objects
parentd82c3105cced4ef0b8d99f1703dda4c4bf4cc0b5 (diff)
downloadcpython-f1d60a53845d2efeccdb61bebf6ee8df94df16d4.zip
cpython-f1d60a53845d2efeccdb61bebf6ee8df94df16d4.tar.gz
cpython-f1d60a53845d2efeccdb61bebf6ee8df94df16d4.tar.bz2
needforspeed: speed up unicode repeat, unicode string copy
Diffstat (limited to 'Objects')
-rw-r--r--Objects/unicodeobject.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7d11f7d..6f04a6d 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -5898,10 +5898,13 @@ unicode_repeat(PyUnicodeObject *str, Py_ssize_t len)
p = u->str;
- while (len-- > 0) {
- Py_UNICODE_COPY(p, str->str, str->length);
- p += str->length;
- }
+ if (str->length == 1 && len > 0) {
+ Py_UNICODE_FILL(p, str->str[0], len);
+ } else
+ while (len-- > 0) {
+ Py_UNICODE_COPY(p, str->str, str->length);
+ p += str->length;
+ }
return (PyObject*) u;
}