refactor(l1,l2): remove duplicate bytes-to-nibbles conversion#6156
Open
viktorking7 wants to merge 3 commits into
Open
refactor(l1,l2): remove duplicate bytes-to-nibbles conversion#6156viktorking7 wants to merge 3 commits into
viktorking7 wants to merge 3 commits into
Conversation
Greptile OverviewGreptile SummaryThis PR eliminates code duplication by removing the standalone
The refactoring is safe and maintains identical behavior while improving maintainability. Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| crates/common/trie/nibbles.rs | Removed duplicate keybytes_to_hex function, replaced with Nibbles::from_raw call in compact_to_hex |
Sequence Diagram
sequenceDiagram
participant Caller
participant decode_compact
participant compact_to_hex
participant from_raw
participant from_hex
Caller->>decode_compact: Nibbles::decode_compact(compact)
decode_compact->>compact_to_hex: compact_to_hex(compact)
alt compact is empty
compact_to_hex-->>decode_compact: return vec![]
else compact has data
compact_to_hex->>from_raw: Nibbles::from_raw(compact, true)
Note over from_raw: Split bytes into nibbles:<br/>(byte >> 4 & 0x0F), byte & 0x0F<br/>Add terminator nibble 16
from_raw-->>compact_to_hex: Nibbles with data vec
compact_to_hex->>compact_to_hex: into_vec() to extract data
alt base[0] < 2 (extension node)
compact_to_hex->>compact_to_hex: Remove terminator (16)
end
compact_to_hex->>compact_to_hex: Calculate chop = 2 - (base[0] & 1)
Note over compact_to_hex: Remove prefix based on odd/even flag
compact_to_hex-->>decode_compact: return base[chop..]
end
decode_compact->>from_hex: Nibbles::from_hex(result)
from_hex-->>Caller: Nibbles instance
ElFantasma
approved these changes
Feb 11, 2026
Author
|
@ElFantasma lint fixed |
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.
The
compact_to_hexfunction innibbles.rscontained a duplicate implementation of the bytes-to-nibbles conversion logic that already exists inNibbles::from_raw. This duplication increases maintenance burden and risk of divergence.