MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / reserve

Method reserve

src/fast.rs:90–109  ·  view source on GitHub ↗
(&mut self, additional: usize)

Source from the content-addressed store, hash-verified

88 }
89
90 pub fn reserve(&mut self, additional: usize) {
91 if additional > sub_ptr(self.capacity, self.end) {
92 #[cold]
93 #[inline(never)]
94 fn reserve_slow<T>(me: &mut FastVec<T>, additional: usize) {
95 // Safety: `Vec::reserve` panics on OOM without freeing Vec, so Vec is unmodified.
96 unsafe {
97 me.mut_vec(|v| {
98 // Optimizes out a redundant check in `Vec::reserve`.
99 // Safety: we've already ensured this condition before calling reserve_slow.
100 if additional <= v.capacity().wrapping_sub(v.len()) {
101 std::hint::unreachable_unchecked();
102 }
103 v.reserve(additional);
104 });
105 }
106 }
107 reserve_slow(self, additional);
108 }
109 }
110
111 /// Accesses the [`FastVec`] mutably as a [`Vec`].
112 /// # Safety

Callers 7

pack_arithmeticFunction · 0.45
unpack_arithmeticFunction · 0.45
reserve_slowMethod · 0.45
test_as_sliceFunction · 0.45
bench_push_fastFunction · 0.45
bench_reserveFunction · 0.45
bench_reserve_fastFunction · 0.45

Calls 1

sub_ptrFunction · 0.85

Tested by 1

test_as_sliceFunction · 0.36