Commit 20c1ec26 authored by Rob Pike's avatar Rob Pike

pick off special one-byte case in copy. worth 2x in benchmarks (38ns->16ns).

the one-item case could be generalized easily with no cost. worth considering.

R=rsc
CC=golang-dev, cw
https://golang.org/cl/167044
parent 80e17d67
......@@ -208,7 +208,11 @@ runtime·slicecopy(Slice to, Slice fm, uintptr width, int32 ret)
if(to.len < ret)
ret = to.len;
memmove(to.array, fm.array, ret*width);
if(ret == 1 && width == 1) { // common case worth about 2x to do here
*to.array = *fm.array; // known to be a byte pointer
} else {
memmove(to.array, fm.array, ret*width);
}
out:
FLUSH(&ret);
......
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