Skip to content

[1196] string_to_scheme_tree 单元测试、性能测试与优化 - #4279

Open
da-liii wants to merge 2 commits into
MoganLab:mainfrom
da-liii:da/1196/string_scheme
Open

[1196] string_to_scheme_tree 单元测试、性能测试与优化#4279
da-liii wants to merge 2 commits into
MoganLab:mainfrom
da-liii:da/1196/string_scheme

Conversation

@da-liii

@da-liii da-liii commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

改动内容

glue 绑定

  • 新增 string->stree(调用 C++ string_to_scheme_tree)和 stree->string(调用 C++ scheme_tree_to_string

单元测试(TeXmacs/tests/1196.scm

116 个断言覆盖:

  • 纯空白输入、简单原子(标识符、特殊字符、前后空白)
  • 简单列表(单/多元素、空列表、空白规范化)
  • 嵌套列表(1-3 层嵌套、兄弟节点混合)
  • Quote 表达式(冒烟)
  • 字符串字面量(简单、含空格)
  • 转义序列(\\, \", \n, \t, \0
  • 注释(顶层、列表内、列表末尾、[19_3] lang_zh_CN: english-chinese.scm #1131 regression)
  • Unicode / 多语言(中文、日文、希腊字母)
  • 数字(解析为 Scheme int)
  • 布尔值(#t / #f
  • 边界情况(全注释、嵌套空列表、长标识符、特殊字符开头标识符)

性能测试

16 项基准覆盖简单/中等/大型/深层嵌套/宽列表/长字符串/混合结构

性能优化

  • 查表法字符分类char_type[256] 替换分支繁多的 is_spc / is_paren_or_spc
  • 无转义快路径:token 和字符串字面量无反斜杠时直取子串,跳过 unslash

🤖 Generated with Claude Code

@da-liii
da-liii force-pushed the da/1196/string_scheme branch 2 times, most recently from 3a339d5 to 2ede761 Compare August 10, 2026 02:04
- glue: 暴露 string->stree 和 stree->string 到 Scheme
- 单元测试: 116 个断言覆盖原子/列表/嵌套/quote/字符串/转义/注释/Unicode/数字/布尔值/边界
- 性能测试: 16 项基准,包含 before/after 对比
- 优化: 查表法字符分类(char_type[256] 替换 is_spc/is_paren_or_spc 多分支判断,
  skip_scheme_blanks 循环合并空白+注释检测为单次查表)

优化效果:深层嵌套提升 6.7%,长字符串提升 7.4%,无回退。

Co-Authored-By: Claude <noreply@anthropic.com>
@da-liii
da-liii force-pushed the da/1196/string_scheme branch from 2ede761 to 9b0f407 Compare August 10, 2026 03:52
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