MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / growTrivial

Method growTrivial

Sources/Shared/Containers/SmallVector.cpp:126–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124 // Note: Moving this function into the header may cause performance regression.
125 template<class Size_T>
126 void SmallVectorBase<Size_T>::growTrivial(void* firstEl, std::size_t minSize, std::size_t typeSize) {
127 std::size_t newCapacity = getNewCapacity<Size_T>(minSize, typeSize, this->capacity());
128 void* newElts;
129 if (BeginX == firstEl) {
130 newElts = std::malloc(newCapacity * typeSize);
131 if (newElts == firstEl) {
132 newElts = replaceAllocation(newElts, typeSize, newCapacity);
133 }
134 // Copy the elements over. No need to run dtors on PODs.
135 std::memcpy(newElts, this->BeginX, size() * typeSize);
136 } else {
137 // If this wasn't grown from the inline copy, grow the allocated space.
138 newElts = std::realloc(this->BeginX, newCapacity * typeSize);
139 if (newElts == firstEl) {
140 newElts = replaceAllocation(newElts, typeSize, newCapacity, size());
141 }
142 }
143
144 this->setAllocationRange(newElts, newCapacity);
145 }
146
147 template class SmallVectorBase<uint32_t>;
148

Callers

nothing calls this directly

Calls 4

capacityMethod · 0.95
setAllocationRangeMethod · 0.95
replaceAllocationFunction · 0.85
sizeFunction · 0.85

Tested by

no test coverage detected