perf(gpos): writeEmptyPosSubtable 空 subtable coverageOff 直接写常量

supported lookup 未命中 subtable(初夏 577 个)走空路径,原用
reserveOffset16(subStart, () => coverageAfter) 写 coverageOff——但 SinglePos/PairPos/
Cursive 的 coverageOff 是相对 subStart 的编译期固定常量(6/10),无需 patch 回填。
改直接 writeUint16(常量),省 per-subtable 的 patch 对象 + 闭包分配 + flush 遍历回填。

字节一致性:8 字体 GPOS 输出 sha 全 IDENTICAL。
性能 best-of 6000(min):初夏纯标点 0.0354→0.0303(-14%)、初夏汉字标点 -14%、
FiraCode -14%、霞鹜/得意黑 -3~5%;思源/鸿蒙噪声级(绝对 <0.0003ms)。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
崮生(子虚) 2026-07-25 06:46:55 +08:00
parent bda73ccea8
commit 6d224c2405

View File

@ -83,13 +83,12 @@ function writeEmptyPosSubtable(w: Writer, effectiveType: number): void {
return;
}
/** coverageOffset 槽(相对 subtable 起始coverage 紧随本类型头部之后 */
const coverageAfter = (() => {
if (effectiveType === LT_SINGLE_POS) return subStart + 6;
if (effectiveType === LT_PAIR_POS) return subStart + 10;
return subStart + 6; /** CursivePos / ContextPos / ChainContextPos */
})();
w.reserveOffset16(subStart, () => coverageAfter);
/** coverageOffset subtable SinglePos 6 PairPos 10
* Cursive/Context 6 coverage subtable coverageOff
* 6/10 reserveOffset16 + + patch push + flush supported lookup
* subtable 577 patch + */
const coverageOffConst = effectiveType === LT_PAIR_POS ? 10 : 6;
w.writeUint16(coverageOffConst);
if (effectiveType === LT_SINGLE_POS) {
w.writeUint16(0); /** valueFormat = 0 */
} else if (effectiveType === LT_PAIR_POS) {