-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Make type 1 font program decryption faster. #6933
Conversation
decryptAscii() also probably needs a similar treatment |
1139665
to
9b21584
Compare
Changed it to gracefully handle a bad discard number instead of asserting. |
9b21584
to
a5f70c0
Compare
Last failure was from some debug code to find a decryptASCII use. Interesting that we only have one PDF that uses that. |
if (discardNumber > data.length) { | ||
return new Uint8Array(0); | ||
} | ||
var r = key | 0, c1 = 52845, c2 = 22719, i = 0, j = 0; |
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.
You already initialize i
and j
to 0 in the loops, so we can remove the initialization here to avoid doing it twice.
Discard the values first so we don't have to slice the array.
a5f70c0
to
02331f6
Compare
} | ||
var r = key | 0, c1 = 52845, c2 = 22719, i, j; | ||
for (i = 0; i < discardNumber; i++) { | ||
r = ((data[i] + r) * c1 + c2) & ((1 << 16) - 1); |
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.
Given that ((1 << 16) - 1)
is constant in all the loop iterations, would it make sense to cache this value in a variable instead?
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.
Talked with one of the spider monkey people, the value will be constant folded by the parser, so it doesn't matter.
@brendandahl Could you address the comment above? Also, do you want to do this for |
This one is more tricky and we only have one example, so I don't think it's worth it unless we see it show up on performance profile. |
/botio-linux preview |
From: Bot.io (Linux)ReceivedCommand cmd_preview from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/951a9d35779dbae/output.txt |
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/951a9d35779dbae/output.txt Total script time: 0.81 mins Published |
/botio test |
From: Bot.io (Windows)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.22.172.223:8877/bcfa87fea2f784e/output.txt |
From: Bot.io (Linux)ReceivedCommand cmd_test from @timvandermeij received. Current queue size: 0 Live output at: http://107.21.233.14:8877/3455e24635d82ec/output.txt |
From: Bot.io (Windows)SuccessFull output at http://107.22.172.223:8877/bcfa87fea2f784e/output.txt Total script time: 19.94 mins
|
From: Bot.io (Linux)SuccessFull output at http://107.21.233.14:8877/3455e24635d82ec/output.txt Total script time: 21.25 mins
|
Make type 1 font program decryption faster.
Nice work, thanks! |
Discard the values first so we don't have to slice the array.
I noticed this showed up pretty high in a profile so I checked it out. In chrome I see 31ms improvement and in firefox a 13ms improvement in the decrypt time while loading the first two pages of trace monkey.