feat: resolveHash from varStore, fix double bootstrap #22
Reference in New Issue
Block a user
Delete Branch "feat/18-resolve-from-varstore"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
resolveTypeHash() → resolveHash(input, varStore),从 varStore 查询替代内存 map。修复双倍 bootstrap 问题。
Why
Phase 2 — 彻底消除 builtinSchemas 内存 map,所有 name→hash 解析统一走 varStore。同时修复 Phase 1 review 中提出的 openVarStore 双倍 bootstrap 效率问题。
Changes
prepareStore(dir)(不含 bootstrap),openStore委托给它prepareStoreisHash()+ 同步resolveHash(input, varStore);openStoreAndVarStore()只 bootstrap 一次;删除旧的builtinSchemasmapRef
Fixes #18
LGTM ✅ 重构干净,双倍 bootstrap 问题解决得很好。
亮点:
prepareStore拆分合理,CLI 可以控制 bootstrap 时机openStoreAndVarStore()单次 bootstrap,效率问题彻底解决resolveHash改同步 + 接受 varStore 参数,消除了隐藏的 store 创建两个小 nit(不阻塞):
isHash用[0-9A-Z]{13}— Crockford Base32 排除了 I/L/O/U,严格写法是[0-9A-HJKMNP-TV-Z]{13}(测试里就是这么写的)。作为快速判断问题不大,但如果用户误传含 I/L/O/U 的字符串会跳过 varStore 查询直接当 hash 用。cmdRender里的(storeAndVarStore as { store: Store; varStore: VariableStore }).varStore类型断言稍丑,可以考虑统一用openStoreAndVarStore然后 pipe 模式也拿到 varStore(反正 close 就好)。合!