Brings ~55 mod-exclusive files to the upstream-based mod/master-resync branch: Activities (migrated to new ActivityManager pattern): - Clock/Time: SetTimeActivity, SetTimezoneOffsetActivity, NtpSyncActivity - Dictionary: DictionaryDefinitionActivity, DictionarySuggestionsActivity, DictionaryWordSelectActivity, LookedUpWordsActivity - Bookmark: EpubReaderBookmarkSelectionActivity - Book management: BookManageMenuActivity, EndOfBookMenuActivity - OPDS: OpdsServerListActivity, OpdsSettingsActivity - Utility: DirectoryPickerActivity, NumericStepperActivity Utilities (unchanged): - BookManager, BookSettings, BookmarkStore, BootNtpSync - Dictionary, LookupHistory, TimeSync, OpdsServerStore Libraries: PlaceholderCover, TableData, ChapterXPathIndexer Scripts: inject_mod_version, generate_book_icon, preview_placeholder_cover Docs: KOReader sync XPath mapping Migration changes: - ActivityWithSubactivity -> Activity base class - Callback constructors -> finish()/setResult() pattern - enterNewActivity() -> startActivityForResult() - Activity::RenderLock&& -> RenderLock&& These files won't compile yet - they reference mod settings and I18n strings that will be added in subsequent phases. Made-with: Cursor
1.4 KiB
1.4 KiB
Port Upstream PR #1027: ParsedText Word-Width Cache and Hyphenation Early Exit
Task
Ported upstream PR #1027 (jpirnay) into the mod. The PR reduces ParsedText::layoutAndExtractLines CPU time by 5–9% via two independent optimizations.
Changes Made
lib/Epub/Epub/ParsedText.cpp (single file):
- Added
#include <cstring>formemcpy/memcmp - Added 128-entry direct-mapped word-width cache in the anonymous namespace (
WordWidthCacheEntry, FNV-1a hash,cachedMeasureWordWidth). 4 KB in BSS, zero heap allocation. - Switched
calculateWordWidthsto usecachedMeasureWordWidthinstead ofmeasureWordWidth - Added
lineBreakIndices.reserve(totalWordCount / 8 + 1)incomputeLineBreaks - In
hyphenateWordAtIndex: added reusableprefixstring buffer (avoids per-iterationsubstrallocations) and early exitbreakwhen prefix exceeds available width (ascending byte-offset order means all subsequent candidates will also be too wide)
mod/prs/MERGED.md: Added PR #1027 entry (TOC link + full section with context, changes, differences, discussion).
Key Adaptation
The upstream PR targets std::list-based code, but our mod already uses std::vector (from PR #1038). List-specific optimizations (splice in extractLine, std::next vs std::advance, continuesVec pointer sync) were not applicable. Only the algorithmic improvements were ported.
Follow-up Items
- None. Port is complete.