Skip to content

[0146] 焦点图标工具栏性能优化#3445

Open
da-liii wants to merge 10 commits into
mainfrom
da/0146/new_doc_imp
Open

[0146] 焦点图标工具栏性能优化#3445
da-liii wants to merge 10 commits into
mainfrom
da/0146/new_doc_imp

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

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

Summary

  • 缓存 hidden_packagedescendance 调用结果,避免每次检查包是否隐藏时重复扫描文件系统(67ms → 14ms)
  • 缓存 style-menu/add-package-menu 等静态菜单的展开结果,避免重复构建
  • 清理菜单展开系统中的 bench 调试日志

性能改善

指标 优化前 优化后
hidden_package 过滤 67ms 14ms
resume 总耗时 245ms 155ms

Test plan

  • 启动 Mogan,打开文档,验证焦点图标工具栏正常显示
  • 切换焦点位置,验证 Style/Package 菜单正常工作
  • 验证无 bench 日志残留输出

🤖 Generated with Claude Code

da-liii and others added 10 commits May 20, 2026 22:32
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- get_style_menu() 等 4 个函数添加 static object cache,避免重复调用 descendance + eval
- menu-expand-link 中添加 static-menu-link? 识别静态菜单,缓存展开结果
- 添加诊断日志用于定位 menu-expand 递归展开的耗时分布

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
hidden_package 每次调用都重新执行 descendance("$TEXMACS_PACKAGE_ROOT")
扫描文件系统,4个包累计耗时 67ms。改为 static 局部变量缓存后降至
~14ms,resume 总耗时从 245ms 降至 155ms。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
移除 menu-expand-link、menu-expand-dynamic、menu-expand-list 中的
texmacs-time 计时和 display* 输出。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
还原 focus-variants-of、cursor-inside?、focus-has-preferences?、
focus-has-parameters? 中的 texmacs-time 计时包装和 display* 输出。

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>
- 将 hidden_package 从逐包递归遍历改为预构建 hash set,查找 O(1)
- 复用 descendance("$TEXMACS_PACKAGE_ROOT") 结果,避免重复扫描
- 在 init_texmacs 启动阶段触发 ensure_hidden_package_set,不再延迟到菜单展开

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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