Skip to content

Commit

Permalink
Avoid copying by creating new Uint8Array with TypedArray view as input
Browse files Browse the repository at this point in the history
  • Loading branch information
robwalch committed Oct 2, 2023
1 parent 428f705 commit f8b66dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/controller/eme-controller.ts
Expand Up @@ -544,7 +544,7 @@ class EMEController implements ComponentAPI {
const json = bin2str(new Uint8Array(initData));
try {
const sinf = base64Decode(JSON.parse(json).sinf);
const tenc = parseSinf(new Uint8Array(sinf));
const tenc = parseSinf(sinf);
if (!tenc) {
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/crypt/decrypter.ts
Expand Up @@ -85,7 +85,8 @@ export default class Decrypter {
): Promise<ArrayBuffer> {
if (this.useSoftware) {
return new Promise((resolve, reject) => {
this.softwareDecrypt(new Uint8Array(data), key, iv);
const dataView = ArrayBuffer.isView(data) ? data : new Uint8Array(data);
this.softwareDecrypt(dataView, key, iv);
const decryptResult = this.flush();
if (decryptResult) {
resolve(decryptResult.buffer);
Expand Down

0 comments on commit f8b66dc

Please sign in to comment.