slice: Refactor for improved performance.

This commit is contained in:
David Braun 2017-10-17 10:32:19 -04:00
parent 10e4fdc083
commit 04bbe30a00

View file

@ -203,12 +203,20 @@ const Channel = function(bufferLength = 0) {
slice: (start, end = Infinity) => {
const output = Channel();
(async () => {
for (let index = 0; index < end; index++) {
for (let index = 0; index < start; index++) {
const value = await readOnly.shift();
if (value === undefined) {
break;
} else if (index >= start) {
}
}
for (let index = start; index < end; index++) {
const value = await readOnly.shift();
if (value === undefined) {
break;
} else {
await output.push(value);
}
}