summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/unicodeobject.c')
-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;
}