Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 0616c78

Browse files
committed
FMT
1 parent 7863ee6 commit 0616c78

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

primitives/trie/src/cache/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ mod tests {
586586

587587
// Check that all items are there.
588588
assert!(shared_cache
589-
.read_lock_inner()
589+
.read_lock_inner()
590590
.value_cache()
591591
.lru
592592
.iter()
@@ -606,7 +606,7 @@ mod tests {
606606

607607
// Ensure that the accessed items are most recently used items of the shared value cache.
608608
assert!(shared_cache
609-
.read_lock_inner()
609+
.read_lock_inner()
610610
.value_cache()
611611
.lru
612612
.iter()

primitives/trie/src/cache/shared_cache.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,16 @@ impl<H: AsRef<[u8]> + Eq + std::hash::Hash> SharedNodeCache<H> {
7878
added: impl IntoIterator<Item = (H, NodeOwned<H>)>,
7979
accessed: impl IntoIterator<Item = H>,
8080
) {
81-
let update_size_in_bytes =
82-
|size_in_bytes: &mut usize, key: &H, node: &NodeOwned<H>| {
83-
if let Some(new_size_in_bytes) =
84-
size_in_bytes.checked_sub(key.as_ref().len() + node.size_in_bytes())
85-
{
86-
*size_in_bytes = new_size_in_bytes;
87-
} else {
88-
*size_in_bytes = 0;
89-
tracing::error!(target: LOG_TARGET, "`SharedNodeCache` underflow detected!",);
90-
}
91-
};
81+
let update_size_in_bytes = |size_in_bytes: &mut usize, key: &H, node: &NodeOwned<H>| {
82+
if let Some(new_size_in_bytes) =
83+
size_in_bytes.checked_sub(key.as_ref().len() + node.size_in_bytes())
84+
{
85+
*size_in_bytes = new_size_in_bytes;
86+
} else {
87+
*size_in_bytes = 0;
88+
tracing::error!(target: LOG_TARGET, "`SharedNodeCache` underflow detected!",);
89+
}
90+
};
9291

9392
accessed.into_iter().for_each(|key| {
9493
// Access every node in the lru to put it to the front.

0 commit comments

Comments
 (0)