Skip to content

Sort toc#2

Open
clbarnes wants to merge 4 commits intofjall-rs:mainfrom
clbarnes:sort-toc
Open

Sort toc#2
clbarnes wants to merge 4 commits intofjall-rs:mainfrom
clbarnes:sort-toc

Conversation

@clbarnes
Copy link
Copy Markdown

@clbarnes clbarnes commented Jan 5, 2026

Allow the table of contents to be sorted by name so that section lookups can use a binary search. Only switches to binary search when the table length reaches a threshold length.

Unsorted usage is unchanged.

Also, utility methods to sort it.
Convert static method to instance method
@marvin-j97 marvin-j97 added the enhancement New feature or request label Jan 12, 2026
@clbarnes
Copy link
Copy Markdown
Author

If preferred, it would also be easy enough to use a proper map here (indexmap would preserve the on-disk order; btreemap would enforce lexicographic order). This would obviously have much better lookup characteristics for larger archives and negligible creation cost compared to IO. I just went for ordering the Toc as it was minimally invasive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants