[0126] 优化 smart_font 字体加载性能#3361
Open
da-liii wants to merge 2 commits into
Open
Conversation
f6b589d to
7605d0c
Compare
通过缓存避免字体加载过程中的重复调用: 1. 添加 maybe_initialize_font,避免对已初始化子字体重复调用 initialize_font 2. 缓存 family tokenize 结果,避免 resolve 和 is_italic_prime 中重复分割字符串 3. 缓存 logical_font 结果,避免 resolve(c, fam, attempt) 中重复计算 4. 缓存 is_italic_prime 的结果 同时添加 test_performance 和 test_math_performance 回归测试。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
7605d0c to
341695f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
通过缓存避免 smart_font 字体加载过程中的重复函数调用:
maybe_initialize_font:在resolve和resolve_rubber中,避免对已初始化的子字体重复调用initialize_fontfamily_tokens:在构造函数中缓存trimmed_tokenize(family, ",")结果,避免resolve(string c)和is_italic_prime中重复分割字符串given_font:在构造函数中缓存logical_font结果,避免resolve(c, fam, attempt)中重复计算is_italic_prime结果:避免对同一字体的斜体引号判断重复计算Test plan
xmake r smart_font_test全部通过(11 个测试用例)test_performance和test_math_performance回归测试覆盖大量字符解析场景🤖 Generated with Claude Code