Skip to content

Commit 47af90f

Browse files
committed
FIX: Handle the case when resize_cold() would be a no-op
This is a safety measure, normally resize_cold() wouldn't been called when here is nothing to do. But we want to ensure that if this ever happens we don't run into a panicking corner case.
1 parent 9f18d10 commit 47af90f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,11 @@ impl<H, T> HeaderVec<H, T> {
273273
);
274274
let old_capacity = self.capacity();
275275

276+
// Shortcut when nothing is to be done.
277+
if requested_capacity == old_capacity {
278+
return None;
279+
}
280+
276281
let new_capacity = if requested_capacity > old_capacity {
277282
if exact {
278283
// exact growing

0 commit comments

Comments
 (0)