mirror of
https://github.com/2234839/web-font.git
synced 2026-09-04 23:02:27 +08:00
承接 fda7ab8(format1 损坏 coverage 跳过)。插桩定位剩余 miss 热点:format2 (range) 仅 11 次 miss,但 439 个 range 的 end >= numGlyphs(1652),逐 gid 展开 浪费 ~320 万次 gidLookup 索引(全部 g>=numGlyphs 越界跳过),是 readCoverageRemapped 剩余 55% self time 的绝大头。 将每个 range 的 end clamp 到 numGlyphs-1:start..numGlyphs-1 段与原代码逐 gid 处理 完全相同,numGlyphs..end 段原代码全越界跳过、clamp 后省去空循环。整个 range 越界 (start>=numGlyphs) 时保留 origNonEmpty=true 语义(→ outOfSubset → null),与原代码 逐 gid 遍历全空结果完全等价。 基准 29 用例 SSIM/ink/字节全无回归,FiraCode fontSubset 6.8ms→3.75ms(累计较 优化前 12.2ms -69%)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>