Skip to content

[0021] 优化 utf8-make-string 性能#784

Merged
da-liii merged 3 commits into
mainfrom
da/0021/utf8_make_string
May 11, 2026
Merged

[0021] 优化 utf8-make-string 性能#784
da-liii merged 3 commits into
mainfrom
da/0021/utf8_make_string

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

@da-liii da-liii commented May 11, 2026

Summary

utf8-make-string 从循环 bytevector-append 拼接改为预分配 make-bytevector + bytevector-u8-set! 逐字节填充,复杂度从 O(n²) 降为 O(n)。

Changes

  1. 添加 bench/utf8-make-string.scm 性能基准测试
  2. 优化 utf8-make-string 实现(goldfish/liii/unicode.scm
  3. 补充长字符串边界测试(tests/liii/unicode/utf8-make-string-test.scm
  4. 撰写 devel/0021.md 记录性能数据

Performance

字符类型 优化前 (100次×10000长) 优化后 提升
ASCII 0.793s 0.387s ~2.05x
中文 1.767s 0.730s ~2.42x
Emoji 2.217s 0.890s ~2.49x

Test plan

  • bin/gf tests/liii/unicode/utf8-make-string-test.scm 通过 (20 correct, 0 failed)

🤖 Generated with Claude Code

da-liii and others added 3 commits May 11, 2026 14:39
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>
@da-liii da-liii merged commit 518b0b8 into main May 11, 2026
4 checks passed
@da-liii da-liii deleted the da/0021/utf8_make_string branch May 11, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant