MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / reserve

Method reserve

modules/core/core/include/OpenString/common/sequence.h:326–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

324
325 template <class T, u64 I>
326 void sequence<T, I>::reserve(const u64 size) noexcept
327 {
328 if(size <= this->capacity_)
329 return;
330 byte* allocated_byte = allocator<byte>::allocate_array(size * ELEMENT_SIZE);
331 T* old_data = this->data();
332 const auto source = reinterpret_cast<byte*>(old_data);
333 if(!this->is_empty())
334 {
335 const auto source_end = reinterpret_cast<byte*>(old_data + this->size_);
336 std::move(source, source_end, allocated_byte);
337 }
338 if(!this->is_short())
339 allocator<byte>::deallocate_array(source);
340 this->as_large().heap_storage = reinterpret_cast<T*>(allocated_byte);
341 this->capacity_ = size;
342 }
343
344 template <class T, u64 I>
345 void sequence<T, I>::push_back_uninitialized(const u64 size) noexcept

Callers 3

sequenceMethod · 0.95
ReadMethod · 0.45

Calls 4

dataMethod · 0.95
is_emptyMethod · 0.95
is_shortMethod · 0.95
moveFunction · 0.50

Tested by

no test coverage detected