[0170] 优化首页与 Chat 页面 update_menus 性能#3532
Closed
da-liii wants to merge 2 commits into
Closed
Conversation
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>
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.
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_MENU、SLOT_MAIN_ICONS、SLOT_FOCUS_ICONS、SLOT_SIDE_TOOLS等)增加模式判断:若startupTabMode或chatTabMode为 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