Removes unused retain_max_n_elements() (#34978)
This commit is contained in:
parent
e1260a9604
commit
59c2f35609
|
@ -333,14 +333,3 @@ impl SnapshotKind {
|
||||||
matches!(self, SnapshotKind::IncrementalSnapshot(_))
|
matches!(self, SnapshotKind::IncrementalSnapshot(_))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to retain only max n of elements to the right of a vector,
|
|
||||||
/// viz. remove v.len() - n elements from the left of the vector.
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn retain_max_n_elements<T>(v: &mut Vec<T>, n: usize) {
|
|
||||||
if v.len() > n {
|
|
||||||
let to_truncate = v.len() - n;
|
|
||||||
v.rotate_left(to_truncate);
|
|
||||||
v.truncate(n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue