[0168] 改进 PDF 阅读器性能#3527
Draft
da-liii wants to merge 4 commits into
Draft
Conversation
将 fz_document/fz_stream/fz_buffer 提升为成员变量,在 loadFromFile 时打开并保持到 clear() 或析构时才释放。renderPageToLabel 和 extractPageLinks 直接复用已打开的文档句柄,消除重复打开文档的 巨大开销。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1. 将页面渲染缓存从 QHash 替换为 QCache,默认上限 30 条,防止 大文档反复缩放时内存无限增长。添加 cacheSize/cacheMaxSize 测试 接口和两个单元测试验证淘汰行为。 2. applyZoomToLabels 改为仅调整可见及预加载范围内的 label 尺寸, 避免大文档在 pinch 缩放过程中遍历所有页面 label。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
改进内容
PDF 文档常驻内存
fz_document/fz_stream/fz_buffer提升为成员变量,在loadFromFile时打开并保持到clear()才释放。renderPageToLabel和extractPageLinks直接复用已打开的文档句柄,消除每次渲染重复fz_open_document_with_stream的巨大开销。LRU 缓存淘汰
QHash<PdfPageCacheKey, QPixmap>替换为QCache,默认上限 30 条,自动 LRU 淘汰。懒加载尺寸调整
applyZoomToLabels改为仅调整可见及PRELOAD_MARGIN范围内的 label 尺寸。测试
test_cacheRespectsMaxSizetest_cacheDoesNotGrowUnbounded提交历史
[0168] PDF文档常驻内存,避免每次渲染重新打开[0168] LRU缓存与懒加载尺寸调整[0168] 更新任务文档,标记已完成项🤖 Generated with Claude Code