Sort the mappings *last* in the readCmapTable function (PR 19321 follow-up)

This improves performance of `issue19319.pdf` even more, and locally the rendering time of the second page goes from ~300 ms to ~250 ms, since we avoid sorting a bunch of duplicate entries.
This commit is contained in:
Jonas Jenwald 2026-06-23 13:51:37 +02:00
parent d71fe9025d
commit 9ca13c9a23

View File

@ -1860,7 +1860,6 @@ class Font {
}
// removing duplicate entries
mappings.sort((a, b) => a.charCode - b.charCode);
const finalMappings = [],
seenCharCodes = new Set();
for (const map of mappings) {
@ -1876,7 +1875,7 @@ class Font {
return {
platformId: potentialTable.platformId,
encodingId: potentialTable.encodingId,
mappings: finalMappings,
mappings: finalMappings.sort((a, b) => a.charCode - b.charCode),
hasShortCmap,
};
}