[0019] 优化 string-ref/cursor 性能,消除临时 bytevector 分配#785
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
摘要
新增
utf8->codepoint-at函数,消除string-ref/cursor及基于 cursor 的字符串操作中每次字符访问产生的临时 bytevector 分配。变更内容
新增
utf8->codepoint-at(goldfish/liii/unicode.scm)bytevector-copy再解码消除临时分配 (
goldfish/liii/string-cursor.scm)string-ref/cursorstring-prefix-lengthstring-suffix-lengthstring-prefix?内部辅助函数同步优化 (
goldfish/scheme/char.scm)utf8-string-map的字符解码逻辑新增测试 (
tests/liii/unicode/utf8-to-codepoint-at-test.scm)性能基准测试 (
bench/string-cursor.scm)性能对比
测试
bin/gf tests/liii/unicode/utf8-to-codepoint-at-test.scm— 26 项全部通过bin/gf test tests/liii/string-cursor/— 59 项全部通过