https://issues.dlang.org/show_bug.cgi?id=17485

--- Comment #2 from [email protected] ---
More specifically, if (1) both ranges are built-in arrays, (2) they have the
same element type, and (3) the back range is a single element, we can optimize
this way:

If front and back are disjoint: (front.ptr > back.ptr && front.ptr +
front.length < back.ptr)

-------
ElementType!InputRange e1 = back[0];
back[0] = front[$-1];
memmove(front.ptr+1, front.ptr, front.length-1);
front[0] = e1;
-------

If back is part of front (i.e., front.ptr < back.ptr < front.ptr +
front.length):

--------
ElementType!InputRange e1 = back[0];
memmove(front.ptr+1, front.ptr, back.ptr - front.ptr);
front[0] = e1;
--------

--

Reply via email to