Skip to content

♻️ Refactoring SequenceSet#[] and #ordered_at internals - #774

Open
nevans wants to merge 3 commits into
sequence_set/test-coveragefrom
sequence_set/slice-refactoring
Open

nevans wants to merge 3 commits into
sequence_set/test-coveragefrom
sequence_set/slice-refactoring

Conversation

@nevans

@nevans nevans commented Oct 3, 2026

Copy link
Copy Markdown
Collaborator

With the tests from #773, we can be relatively confident these refactorings are safe and don't change any behavior.

@nevans
nevans added this pull request to stack #775 October 3, 2026 00:32
nevans added 3 commits October 3, 2026 09:38
This extracts a private inner API layer for number indexing and does the
input/output conversion in the public API layer.  The private API will
be more convenient to work with internally, since we don't need to worry
about accidentally comparing integers to `:*`.

This comes at the small cost of some duplication.  That duplication is
considered less important here because 1) it's very simple, and 2) the
implementations may drift apart:
* `#at` converts _indexable_ runs into indexable nums,
* `#ordered_at` converts _enumerable_ runs into indexable nums.
Since `set[2**32]` will _always_ be out of bounds, this makes no
difference to the semantics.  And it should have no effect on
performance.

Future performance optimizations can special case when we _know_ we must
be scanning to the end, but that would check for `STAR_INT <= last`.
@nevans
nevans force-pushed the sequence_set/slice-refactoring branch from b608d7f to 4bf5bb4 Compare October 3, 2026 13:42

This branch has not been deployed

No deployments
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