diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-10-20 21:08:34 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-10-20 21:08:34 (GMT) |
commit | 6f7b0da6bcbcb5a873d8315e49db4096895fc2eb (patch) | |
tree | b17875c3e50812957996c2fa3957069267f1ea1e /Objects/stringlib | |
parent | 257c1323f7902cfe33f7614223a4b1a116b5eeb0 (diff) | |
download | cpython-6f7b0da6bcbcb5a873d8315e49db4096895fc2eb.zip cpython-6f7b0da6bcbcb5a873d8315e49db4096895fc2eb.tar.gz cpython-6f7b0da6bcbcb5a873d8315e49db4096895fc2eb.tar.bz2 |
Issue #12805: Make bytes.join and bytearray.join faster when the separator is empty.
Patch by Serhiy Storchaka.
Diffstat (limited to 'Objects/stringlib')
-rw-r--r-- | Objects/stringlib/join.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/stringlib/join.h b/Objects/stringlib/join.h index 21753cb..d1d6e53 100644 --- a/Objects/stringlib/join.h +++ b/Objects/stringlib/join.h @@ -94,6 +94,16 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) /* Catenate everything. */ p = STRINGLIB_STR(res); + if (!seplen) { + /* fast path */ + for (i = 0; i < nbufs; i++) { + Py_ssize_t n = buffers[i].len; + char *q = buffers[i].buf; + Py_MEMCPY(p, q, n); + p += n; + } + goto done; + } for (i = 0; i < nbufs; i++) { Py_ssize_t n; char *q; |