Skip to content

Reuse section layout state when saving - #171

Merged
serge1 merged 1 commit into
serge1:mainfrom
quadratic-bit:main
Aug 7, 2026
Merged

serge1 merged 1 commit into
serge1:mainfrom
quadratic-bit:main

Conversation

@quadratic-bit

Copy link
Copy Markdown
Contributor

layout_sections_without_segments() repeatedly calls is_section_without_segment(), even though it is equivalent to section_generated[i] == false for section with index i. section_generated is created in layout_segments_and_their_sections() and discarded afterwards, but it would be faster to reuse it.

This patch brings layout_sections_without_segments from O(S*M) down to O(S), where S is the number of sections and M is the number of segment-to-section associations. I see around 30-40% runtime speedup, especially for large number of segments.

Reuse the section-generation bitmap produced during segment layout to
identify sections that do not belong to any segment. This avoids
repeatedly scanning every segment and its section list for each section
during serialization.
@serge1
serge1 merged commit 16178a7 into serge1:main Aug 7, 2026
20 checks passed
@serge1

serge1 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Accepted.
Thank you!

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.

2 participants