Skip to content

Commit 680010d

Browse files
committed
CRC: use a min instead of awkward if statement inside array access
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 5be43bf commit 680010d

File tree

1 file changed

+2
-7
lines changed
  • stackslib/src/chainstate/stacks/index

1 file changed

+2
-7
lines changed

stackslib/src/chainstate/stacks/index/trie.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,13 +378,8 @@ impl Trie {
378378
// append the new leaf and the end of the file.
379379
let new_leaf_disk_ptr = storage.last_ptr()?;
380380
let new_leaf_chr = cursor.path[cursor.tell()]; // NOTE: this is safe because !cursor.eop()
381-
let new_leaf_path = cursor.path[(if cursor.tell() < cursor.path.len() {
382-
cursor.tell() + 1
383-
} else {
384-
cursor.path.len()
385-
})..]
386-
.to_vec();
387-
new_leaf_data.path = new_leaf_path;
381+
new_leaf_data.path =
382+
cursor.path[std::cmp::min(cursor.tell() + 1, cursor.path.len())..].to_vec();
388383
let new_leaf_hash = get_leaf_hash(new_leaf_data);
389384

390385
// put new leaf at the end of this Trie

0 commit comments

Comments
 (0)