buffer: improve copy() performance
There is no need to create a slice when sourceEnd
is out of bounds.
Results of included benchmark:
confidence improvement accuracy (*) (**) (***)
buffers\\buffer-copy.js n=6000000 oob='false' partial='false' bytes=0 3.30 % ±4.96% ±6.62% ±8.65%
buffers\\buffer-copy.js n=6000000 oob='false' partial='false' bytes=128 -0.66 % ±3.54% ±4.71% ±6.13%
buffers\\buffer-copy.js n=6000000 oob='false' partial='false' bytes=32768 -3.02 % ±8.44% ±11.30% ±14.83%
buffers\\buffer-copy.js n=6000000 oob='false' partial='false' bytes=8 2.80 % ±5.54% ±7.37% ±9.61%
buffers\\buffer-copy.js n=6000000 oob='false' partial='true' bytes=0 2.29 % ±4.58% ±6.10% ±7.98%
buffers\\buffer-copy.js n=6000000 oob='false' partial='true' bytes=128 1.90 % ±3.39% ±4.52% ±5.88%
buffers\\buffer-copy.js n=6000000 oob='false' partial='true' bytes=32768 0.23 % ±7.59% ±10.10% ±13.16%
buffers\\buffer-copy.js n=6000000 oob='false' partial='true' bytes=8 2.75 % ±4.06% ±5.42% ±7.07%
buffers\\buffer-copy.js n=6000000 oob='true' partial='false' bytes=0 2.68 % ±4.89% ±6.52% ±8.50%
buffers\\buffer-copy.js n=6000000 oob='true' partial='false' bytes=128 *** 135.43 % ±7.70% ±10.31% ±13.57%
buffers\\buffer-copy.js n=6000000 oob='true' partial='false' bytes=32768 * 5.98 % ±4.85% ±6.46% ±8.40%
buffers\\buffer-copy.js n=6000000 oob='true' partial='false' bytes=8 *** 142.55 % ±10.22% ±13.71% ±18.06%
buffers\\buffer-copy.js n=6000000 oob='true' partial='true' bytes=0 4.42 % ±4.67% ±6.26% ±8.23%
buffers\\buffer-copy.js n=6000000 oob='true' partial='true' bytes=128 0.66 % ±2.75% ±3.66% ±4.77%
buffers\\buffer-copy.js n=6000000 oob='true' partial='true' bytes=32768 -1.10 % ±7.26% ±9.67% ±12.59%
buffers\\buffer-copy.js n=6000000 oob='true' partial='true' bytes=8 2.74 % ±3.92% ±5.23% ±6.82%
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
commit message follows commit guidelines