mirror of
https://github.com/2234839/web-font.git
synced 2026-09-04 23:02:27 +08:00
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:
parent
bda73ccea8
commit
6d224c2405
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user