Repository navigation
Avoid some String.fromCharCode calls in the Lexer.prototype.getString method - #22227
timvandermeij merged 1 commit into
Conversation
…ing` method For a number of known character-sequences we directly push the resulting character, however that's not done for `\\`, `\(`, and `\)` where `String.fromCharCode` is thus used instead. Perhaps the idea was that these cases are uncommon in practice, however when parsing and rendering all pages of `pdf.pdf` (from the test-suite) those cases are hit over `54 000` times. Hence it seems that it cannot hurt to add "fast paths" there as well.
Reference testsResults for 50ab00d (run, references from mozilla/pdf.js.refs@c77f4688b3).
The report is kept for 30 days and replaced by the next run. |
Viewer preview🗑️ Viewer previews removed. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 41.78%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | JBig2CCITTFaxImage.decode: JBIG2 MMR (bitmap-mmr.pdf) |
1.2 ms | 2.1 ms | -41.78% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing Snuffleupagus:Lexer-getString-skip-fromCharCode (50ab00d) with master (157d30e)
|
Thank you for improving this logic! |
For a number of known character-sequences we directly push the resulting character, however that's not done for
\\,\(, and\)whereString.fromCharCodeis thus used instead.Perhaps the idea was that these cases are uncommon in practice, however when parsing and rendering all pages of
pdf.pdf(from the test-suite) those cases are hit over54 000times. Hence it seems that it cannot hurt to add "fast paths" there as well.