Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normative: In the TypedArray(typedArray) constructor, copy only the n…
…eeded portion (#458) The TypedArray constructor includes a "fast path" for a TypedArray input (as opposed to treating it as an iterable), which has a fast path for the case of the same-type input and output. This path calls CloneArrayBuffer. CloneArrayBuffer takes an argument for the start offset, but it did not take an argument for the end, so it copied the underlying ArrayBuffer until the end. The extra wasted copy remains observable, e.g. in cases like new Uint8Array(new Uint8Array(10000).subarray(0, 1)).buffer.byteLength // => 1 or 10000 ? This patch adds an additional argument to CloneArrayBuffer for the length in bytes that should be cloned, so that only the viewed portion of the ArrayBuffer is copied. This does not make an observable change for the other caller (%TypedArray%.prototype.set), where it would have already been valid to apply this optimization. Closes #447
- Loading branch information