Skip to content

[0170] 优化首页与 Chat 页面 update_menus 性能#3532

Closed
da-liii wants to merge 2 commits into
mainfrom
da/0170/perf_menu
Closed

[0170] 优化首页与 Chat 页面 update_menus 性能#3532
da-liii wants to merge 2 commits into
mainfrom
da/0170/perf_menu

Conversation

@da-liii
Copy link
Copy Markdown
Contributor

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

Summary

在首页 (tmfs://startup-tab) 和 Chat 页面 (tmfs://chat-tab) 上,update_menus 仍会被 idle 循环触发,执行完整的菜单/工具栏/状态栏/DRD 更新流程,单次耗时高达 264ms。本 PR 通过双层优化消除这些无意义的调用:

编辑层优化

  • 新增 is_startup_tab_buffer()should_skip_menu_update() 辅助函数
  • edit_interface_rep::update_menus() 入口处检测无菜单 buffer,直接返回并更新 last_update,防止 idle 路径重复触发

Qt Widget 层优化

  • qt_tm_widget_rep::send() 中,对菜单相关 slot(SLOT_MAIN_MENUSLOT_MAIN_ICONSSLOT_FOCUS_ICONSSLOT_SIDE_TOOLS 等)增加模式判断:若 startupTabModechatTabMode 为 true,直接跳过 widget 创建与替换

单元测试

  • tests/Data/buffer_type_test.cpp — 测试 is_startup_tab_buffer()is_chat_tab_buffer()
  • tests/Edit/Interface/update_menus_skip_test.cpp — 测试 should_skip_menu_update()

Test plan

  • xmake b stem 编译通过
  • xmake r buffer_type_test 通过
  • xmake r update_menus_skip_test 通过
  • xmake r view_type_test 通过
  • xmake r invalidate_test 通过
  • xmake r text_popup_test 通过

🤖 Generated with Claude Code

da-liii and others added 2 commits May 28, 2026 09:55
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- 新增 is_startup_tab_buffer() 与 should_skip_menu_update() 辅助函数
- 在 edit_interface_rep::update_menus() 中跳过 startup-tab 和 chat-tab 的菜单更新
- 在 qt_tm_widget_rep::send() 中同步跳过无菜单模式下的 widget 更新
- 新增 buffer_type_test 与 update_menus_skip_test 单元测试

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@da-liii da-liii marked this pull request as draft May 28, 2026 03:11
@da-liii da-liii closed this May 28, 2026
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