perf: Use same reallocation strategy as Vec
This change seems to improve performance on some benchmarks (e.g. techempower), but causes performance regression on another benchmark. We need to measure performance using more test cases.
This commit is contained in:
parent
67f49bdd18
commit
47818c11b7
|
@ -162,11 +162,10 @@ impl Buffer {
|
|||
}
|
||||
|
||||
#[cfg_attr(feature = "perf-inline", inline)]
|
||||
#[cold]
|
||||
fn reserve_internal(&mut self, size: usize) {
|
||||
debug_assert!(size <= std::isize::MAX as usize);
|
||||
|
||||
let new_capacity = std::cmp::max(self.capacity * 2, self.capacity + size);
|
||||
let new_capacity = std::cmp::max(self.capacity * 2, self.len + size);
|
||||
debug_assert!(new_capacity > self.capacity);
|
||||
self.data = unsafe { safe_realloc(self.data, self.capacity, new_capacity) };
|
||||
self.capacity = new_capacity;
|
||||
|
|
Loading…
Reference in New Issue