-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Avoid an allocation in readCharCode(). #5172
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
var c = this.cMap.readCharCode(chars, i); | ||
charcode = c[0]; | ||
var length = c[1]; | ||
var c = this.cMap.readCharCode(chars, i, tmp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: c is unused/undefined here
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/5d8d376bf1abd1b/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/7992db1cca14f86/output.txt |
From: Bot.io (Windows)FailedFull output at http://107.22.172.223:8877/5d8d376bf1abd1b/output.txt Total script time: 21.49 mins
|
From: Bot.io (Linux)FailedFull output at http://107.21.233.14:8877/7992db1cca14f86/output.txt Total script time: 22.57 mins
|
readCharCode() returns two values, and currently allocates a length-2 array on every call to do so. This change makes it instead us a passed-in object which can be reused. This tiny change reduces the total JS allocations done for the document in Mozilla bug 992125 by 4.2%.
Whoops, I forgot to modify the unit tests. They should work now. |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.22.172.223:8877/235f219e3b3a613/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @Snuffleupagus received. Current queue size: 0 Live output at: http://107.21.233.14:8877/46ced159404a71d/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/235f219e3b3a613/output.txt Total script time: 19.68 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/46ced159404a71d/output.txt Total script time: 22.42 mins
|
Avoid an allocation in readCharCode().
Looks good; thanks for the patch! |
readCharCode() returns two values, and currently allocates a length-2
array on every call to do so. This change makes it instead us a
passed-in object which can be reused.
This tiny change reduces the total JS allocations done for the document
in Mozilla bug 992125 by 4.2%.