-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Convert code in src/core/crypto.js
to use "normal" classes
#13026
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ith the `isArrayEqual` helper function The `compareByteArrays` is first of all duplicated in multiple closures in the `src/core/crypto.js` file. Secondly, despite its name, it's also functionally equivalent to the now existing `isArrayEqual` helper function. The `isArrayEqual` helper function is changed to use a standard `for`-loop, rather than `Array.prototype.every`, since that ought to be slightly more efficient given that we're now using it with (potentially) larger data.
This helper function is first of all only called *twice*, and secondly it also leads to unnecessary intermediate allocations given how the `TypedArray`s are handled. Hence we can simply inline this small function, and thus directly allocate the combined `TypedArray` instead.
All of this code predates the existence of native JS classes, however we can now clean this up a bit. This patch thus let us remove some variable "shadowing" from the code.
/botio unittest |
From: Bot.io (Linux m4)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://54.67.70.0:8877/2a3f95e9673a164/output.txt |
From: Bot.io (Windows)ReceivedCommand cmd_unittest from @Snuffleupagus received. Current queue size: 0 Live output at: http://3.101.106.178:8877/8ece92dd06c86a1/output.txt |
From: Bot.io (Linux m4)SuccessFull output at http://54.67.70.0:8877/2a3f95e9673a164/output.txt Total script time: 3.63 mins
|
From: Bot.io (Windows)SuccessFull output at http://3.101.106.178:8877/8ece92dd06c86a1/output.txt Total script time: 5.13 mins
|
Nice readability improvement! |
All of this code predates the existence of native JS classes, however we can now clean this up a bit. This patch thus let us remove some variable "shadowing" from the code.
Much smaller diff with https://github.com/mozilla/pdf.js/pull/13026/files?w=1