Skip to content

Commit

Permalink
CRC: use a min instead of awkward if statement inside array access
Browse files Browse the repository at this point in the history
Signed-off-by: Jacinta Ferrant <[email protected]>
  • Loading branch information
jferrant committed Jan 2, 2025
1 parent 5be43bf commit 680010d
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions stackslib/src/chainstate/stacks/index/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,8 @@ impl Trie {
// append the new leaf and the end of the file.
let new_leaf_disk_ptr = storage.last_ptr()?;
let new_leaf_chr = cursor.path[cursor.tell()]; // NOTE: this is safe because !cursor.eop()
let new_leaf_path = cursor.path[(if cursor.tell() < cursor.path.len() {
cursor.tell() + 1
} else {
cursor.path.len()
})..]
.to_vec();
new_leaf_data.path = new_leaf_path;
new_leaf_data.path =
cursor.path[std::cmp::min(cursor.tell() + 1, cursor.path.len())..].to_vec();
let new_leaf_hash = get_leaf_hash(new_leaf_data);

// put new leaf at the end of this Trie
Expand Down

0 comments on commit 680010d

Please sign in to comment.