refactor: ember-core unreachable removal and sorted_set optimization#122
Merged
refactor: ember-core unreachable removal and sorted_set optimization#122
Conversation
…ning
keyspace.rs:
- list_push: use let-else to destructure Value::List, capture len before
touch() instead of re-matching after mutation
- list_pop: replace expect("verified above") + unreachable!() with
let-else pattern that eliminates the double HashMap lookup
- hincrby: replace unreachable!() else branch with let-else that returns
a proper error
sorted_set.rs:
- add_with_flags: reorder tree/scores inserts so the member is cloned
once (into scores) then moved (into tree), instead of cloning twice
kacy
added a commit
that referenced
this pull request
Feb 19, 2026
…ning (#122) keyspace.rs: - list_push: use let-else to destructure Value::List, capture len before touch() instead of re-matching after mutation - list_pop: replace expect("verified above") + unreachable!() with let-else pattern that eliminates the double HashMap lookup - hincrby: replace unreachable!() else branch with let-else that returns a proper error sorted_set.rs: - add_with_flags: reorder tree/scores inserts so the member is cloned once (into scores) then moved (into tree), instead of cloning twice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
unreachable!()calls in keyspace.rs withlet-elsepatternsthat return proper errors instead of panicking
expect("verified above")double-lookup pattern inlist_popwith a single
get_mut+let-elsesorted_set::add_with_flagsfrom 2 clones to 1by reordering the scores/tree inserts (clone into scores, move into tree)
what was tested
cargo test -p emberkv-core— all 329 tests passcargo check -p emberkv-coredesign considerations
the
let-elsepattern is preferred overif let+unreachable!()becauseit makes the code flow linear and eliminates dead branches. the sorted_set
reorder is safe because both collections are private — no external observer
can see them in an inconsistent intermediate state.