Creating a new `Uint8Array` from the `this.buffer` doesn't work if `subarray` had previously been used (e.g. `slice`), since `this.buffer` still would refer to the start of the buffer, not the start of the subarray. We can use `subarray` here instead, which keeps previous subarray indices intact.
for (var i = 0; i < len; i++)
target[i + target_start] = this[i + start]
} else {
- target._set(new Uint8Array(this.buffer, start, len), target_start)
+ target._set(this.subarray(start, start + len), target_start)
}
}