Skip to content

Use CharCodeMap for font character mappings (bug 2077176) - #22092

Merged
calixteman merged 1 commit into
mozilla:masterfrom
calixteman:fix-cmap-tounicode-perf
Oct 6, 2026
Merged

calixteman merged 1 commit into
mozilla:masterfrom
calixteman:fix-cmap-tounicode-perf

Conversation

@calixteman

Copy link
Copy Markdown
Contributor

Store CMap, ToUnicode and CIDToGIDMap entries in an Array for integer codes in [0, 0xFFFF] and a Map for other codes. Track keys separately to preserve insertion order without scanning array holes.

Cache reverse lookups after eight linear searches, preserving the first matching code. This avoids repeated scans during CFF glyph mapping and string encoding.

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Reference tests

Results for 9558da3 (run, references from mozilla/pdf.js.refs@c37d6059a5).

Platform Status Tests Total runtime Errors Different FBF No reference Report
Linux ✅ 1382 11m 51s 0 0 0 0
Windows ✅ 1382 14m 45s 0 0 0 0

The report is kept for 30 days and replaced by the next run.

@codecov-commenter

codecov-commenter commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.05970% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.26%. Comparing base (c1be1c9) to head (b4aa2af).
⚠️ Report is 33 commits behind head on master.

Files with missing lines Patch % Lines
src/core/fonts.js 44.44% 5 Missing ⚠️
src/core/cmap.js 50.00% 2 Missing ⚠️
src/core/cff_font.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22092      +/-   ##
==========================================
- Coverage   90.28%   89.26%   -1.03%     
==========================================
  Files         269      271       +2     
  Lines       67362    69770    +2408     
==========================================
+ Hits        60819    62280    +1461     
- Misses       6543     7490     +947     
Flag Coverage Δ
fonttest 8.98% <15.87%> (+0.02%) ⬆️
unittestcli 58.30% <88.05%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 6, 2026
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Viewer preview

🗑️ Viewer previews removed.

sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 6, 2026
Comment thread src/core/char_code_map.js
Comment thread src/core/char_code_map.js
Comment thread src/core/char_code_map.js
Comment thread src/core/char_code_map.js Outdated
Store CMap, ToUnicode and CIDToGIDMap entries in an Array for integer
codes in [0, 0xFFFF] and a Map for other codes. Track keys separately
to preserve insertion order without scanning array holes.

Cache reverse lookups after eight linear searches, preserving the
first matching code. This avoids repeated scans during CFF glyph
mapping and string encoding.
@calixteman
calixteman force-pushed the fix-cmap-tounicode-perf branch from 9558da3 to b4aa2af Compare October 6, 2026 19:56
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 6, 2026

@Snuffleupagus Snuffleupagus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, thank you.

@calixteman
calixteman merged commit f46f647 into mozilla:master Oct 6, 2026
22 checks passed
sync-pdfs-for-pdf-js Bot pushed a commit to mozilla/pdf.js.refs that referenced this pull request Oct 6, 2026
@calixteman
calixteman deleted the fix-cmap-tounicode-perf branch October 6, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants