diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2022-10-09 03:08:38 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-09 15:38:38 +0530 |
commit | a622c5df27e908bff152ce7374c47dabfdba0bba (patch) | |
tree | 0c836839a6d359db2afa8baf640860a31decf714 /ext/crypto/00_crypto.js | |
parent | cc3e2b9b1a7ccd6c671bc0b3813cf7e2b0d88b5c (diff) |
perf(ext/crypto): optimize `getRandomValues` (#16212)
Diffstat (limited to 'ext/crypto/00_crypto.js')
-rw-r--r-- | ext/crypto/00_crypto.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/crypto/00_crypto.js b/ext/crypto/00_crypto.js index 907308325..7b21c9287 100644 --- a/ext/crypto/00_crypto.js +++ b/ext/crypto/00_crypto.js @@ -4652,6 +4652,11 @@ webidl.assertBranded(this, CryptoPrototype); const prefix = "Failed to execute 'getRandomValues' on 'Crypto'"; webidl.requiredArguments(arguments.length, 1, { prefix }); + // Fast path for Uint8Array + if (ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, arrayBufferView)) { + ops.op_crypto_get_random_values(arrayBufferView); + return arrayBufferView; + } arrayBufferView = webidl.converters.ArrayBufferView(arrayBufferView, { prefix, context: "Argument 1", |