Skip to content

refactor: Adopt Chapter type, drop denormalized state#60

Merged
znelson merged 2 commits into
mainfrom
chapter-refactor-2
May 24, 2026
Merged

refactor: Adopt Chapter type, drop denormalized state#60
znelson merged 2 commits into
mainfrom
chapter-refactor-2

Conversation

@znelson
Copy link
Copy Markdown
Owner

@znelson znelson commented May 24, 2026

Replace TocBoundary (Section) and SpineSegment (EpubReaderActivity) with the unified Chapter type from phase 1 (PR #56). Delete TocPageRange; getPageRangeForTocIndex now returns std::optional directly.

Drop the denormalized cumulativeOffset and totalPages fields. getChapterRelativePage is rewritten as a running sum over chapterPageInfo.segments (N <= 3 in practice). New getChapterTotalPages() helper exposes the chapter total to status bar and reader menu without storing it on the side.

Section::tocBoundaries now precomputes endPage at build time (post-sort) instead of recomputing it in each getPageRangeForTocIndex call.

No behavior change. RAM unchanged; flash drops ~1.3 KB. On-disk section cache format unchanged (no SECTION_FILE_VERSION bump).

@znelson znelson enabled auto-merge (squash) May 24, 2026 16:32
@znelson znelson merged commit fa94ece into main May 24, 2026
6 checks passed
@znelson znelson deleted the chapter-refactor-2 branch May 24, 2026 16:35
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