Remove unnecessary check in VecDeque::grow
All callers already check that the buffer is full before calling `grow()`. This is where it makes the most sense, since `grow()` is `inline(never)` and we don't want to pay for a function call just for that check. It could also be argued that it would be correct to call `grow()` even if the buffer wasn't full yet. This change breaks no code since `grow()` is not `pub`.
This commit is contained in:
parent
6db0a0e9a4
commit
29f5c98a17
@ -2179,19 +2179,21 @@ impl<T, A: Allocator> VecDeque<T, A> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Double the buffer size. This method is inline(never), so we expect it to only
|
||||||
|
// be called in cold paths.
|
||||||
// This may panic or abort
|
// This may panic or abort
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn grow(&mut self) {
|
fn grow(&mut self) {
|
||||||
if self.is_full() {
|
// Extend or possibly remove this assertion when valid use-cases for growing the
|
||||||
let old_cap = self.cap();
|
// buffer without it being full emerge
|
||||||
// Double the buffer size.
|
debug_assert!(self.is_full());
|
||||||
self.buf.reserve_exact(old_cap, old_cap);
|
let old_cap = self.cap();
|
||||||
assert!(self.cap() == old_cap * 2);
|
self.buf.reserve_exact(old_cap, old_cap);
|
||||||
unsafe {
|
assert!(self.cap() == old_cap * 2);
|
||||||
self.handle_capacity_increase(old_cap);
|
unsafe {
|
||||||
}
|
self.handle_capacity_increase(old_cap);
|
||||||
debug_assert!(!self.is_full());
|
|
||||||
}
|
}
|
||||||
|
debug_assert!(!self.is_full());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`,
|
/// Modifies the `VecDeque` in-place so that `len()` is equal to `new_len`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user