一刀砍干净 HistoryManager 所有 O(N) stat 全扫路径
继上次只修 hot path 之后, 把残留的所有冷热路径都改成 raw json 直接操作, 彻底消灭 load_history_index 内的 stat 循环. 修改: 1. _migrate_paths_once: 启动时一次性路径归一化, 抽样 5 条 60% 阈值 决定是否需要全量迁移, 之后所有路径都是当前 base_path 下的有效绝对路径 2. load_history_index: 简化为 raw read + from_dict + sort, 0 stat N=513 时只需几 ms (旧版 ~60ms) 3. delete_history_item: 改 raw json filter 4. _cleanup_old_records: 改 raw json sort + slice 5. 删除已无调用方的 _save_history_index / _fix_history_path 至此 hot path (生成完成, 点击历史项) 与 cold path (删除, 启动清理) 都不再触发 N 次 stat. 唯一保留全量读的 load_history_index 也只有 refresh_history 一处真实调用方.
Showing
1 changed file
with
140 additions
and
89 deletions
-
Please register or sign in to post a comment