We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a31f1db commit 1368f04Copy full SHA for 1368f04
rs/utils/lru_cache/src/lib.rs
@@ -138,13 +138,18 @@ where
138
}
139
140
fn check_invariants(&self) {
141
- debug_assert_eq!(
142
- self.size,
143
- self.cache
144
- .iter()
145
- .map(|(key, value)| key.count_bytes() + value.count_bytes())
146
- .sum::<usize>()
147
- );
+ // Iterating over random memory locations is expensive and slows down some tests,
+ // so the debug assert is limited to 1k cache entries.
+ #[cfg(debug_assertions)]
+ if self.len() < 1_000 {
+ debug_assert_eq!(
+ self.size,
+ self.cache
148
+ .iter()
149
+ .map(|(key, value)| key.count_bytes() + value.count_bytes())
150
+ .sum::<usize>()
151
+ );
152
+ }
153
debug_assert!(self.size <= self.capacity);
154
155
0 commit comments