mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
dont increase the allocated size of vec (#10701)
This commit is contained in:
@@ -222,16 +222,17 @@ impl<T, S: Get<u32>> BoundedVec<T, S> {
|
||||
/// Returns `true` if the item was inserted.
|
||||
pub fn force_insert_keep_left(&mut self, index: usize, element: T) -> bool {
|
||||
// Check against panics.
|
||||
if Self::bound() < index || self.len() < index {
|
||||
if Self::bound() < index || self.len() < index || Self::bound() == 0 {
|
||||
return false
|
||||
}
|
||||
// Noop condition.
|
||||
if Self::bound() == index && self.len() <= Self::bound() {
|
||||
return false
|
||||
}
|
||||
// Cannot panic since self.len() >= index;
|
||||
// Cannot panic since `Self.bound() > 0`
|
||||
self.0.truncate(Self::bound() - 1);
|
||||
// Cannot panic since `self.len() >= index`;
|
||||
self.0.insert(index, element);
|
||||
self.0.truncate(Self::bound());
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user