Skip to content

Commit 7f2f247

Browse files
committed
feat(allocator/vec2): add specialized grow_one method (oxc-project#9855)
A specialized version of `self.reserve(len, 1)` which requires the caller to ensure `len == self.capacity()`.
1 parent f400a11 commit 7f2f247

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/oxc_allocator/src/vec2/raw_vec.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,15 @@ impl<'a, T> RawVec<'a, T> {
435435
}
436436
}
437437

438+
/// A specialized version of `self.reserve(len, 1)` which requires the
439+
/// caller to ensure `len == self.capacity()`.
440+
#[inline(never)]
441+
pub fn grow_one(&mut self) {
442+
if let Err(err) = self.grow_amortized(self.cap, 1) {
443+
handle_error(err);
444+
}
445+
}
446+
438447
/*
439448
/// Attempts to ensure that the buffer contains at least enough space to hold
440449
/// `len + additional` elements. If it doesn't already have

0 commit comments

Comments
 (0)