mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-26 17:46:26 +03:00
18b59c5294
Using "new Uint8Array" with a TypedArray creates a copy of the buffer; this is unnecessarily expensive for large buffers. This adds a rule to disallow using it in favor of a new utility that correctly creates a new "view" on the same buffer. Note it is fine to pass an ArrayBuffer to "new Uint8Array" and it won't copy; but there there are many cases where the type is BufferSource, so it could be a TypedArray. Unfortunately, there are many other cases where we explicitly pass an ArrayBuffer; but the compiler rules don't allow us to whitelist this case (since ArrayBuffer is part of BufferSource). Change-Id: I58696a85a9cbcc188c0b16919c9eeb63e56edca1