Commit 6f7b0da6 authored by Antoine Pitrou's avatar Antoine Pitrou

Issue #12805: Make bytes.join and bytearray.join faster when the separator is empty.

Patch by Serhiy Storchaka.
parent 257c1323
...@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1? ...@@ -10,6 +10,9 @@ What's New in Python 3.4.0 Alpha 1?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #12805: Make bytes.join and bytearray.join faster when the separator
is empty. Patch by Serhiy Storchaka.
- Issue #6074: Ensure cached bytecode files can always be updated by the - Issue #6074: Ensure cached bytecode files can always be updated by the
user that created them, even when the source file is read-only. user that created them, even when the source file is read-only.
......
...@@ -94,6 +94,16 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable) ...@@ -94,6 +94,16 @@ STRINGLIB(bytes_join)(PyObject *sep, PyObject *iterable)
/* Catenate everything. */ /* Catenate everything. */
p = STRINGLIB_STR(res); 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++) { for (i = 0; i < nbufs; i++) {
Py_ssize_t n; Py_ssize_t n;
char *q; char *q;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment