Skip to content

Commit

Permalink
Use subarray instead of slice for more performant Uint8Array copying
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauren Budorick committed Sep 15, 2017
1 parent 04e9a15 commit f53eaad
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/source/canvas_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class CanvasSource extends ImageSource {
const imageData = this.secondaryContext.createImageData(this.width, this.height);
const flipped = new Uint8Array(this.width * this.height * 4);
for (let i = this.height - 1, j = 0; i >= 0; i--, j++) {
flipped.set(data.slice(i * this.width * 4, (i + 1) * this.width * 4), j * this.width * 4);
flipped.set(data.subarray(i * this.width * 4, (i + 1) * this.width * 4), j * this.width * 4);
}
imageData.data.set(flipped);
return imageData;
Expand Down

0 comments on commit f53eaad

Please sign in to comment.