MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / grow

Method grow

dnn/include/megdnn/thin/small_vector.h:220–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218};
219template <typename T, bool is_pod>
220void SmallVectorTemplateBase<T, is_pod>::grow(size_t min_sz) {
221 size_t cur_capacity = this->capacity();
222 size_t cur_sz = this->size();
223 size_t new_capacity = (cur_capacity + 2) * 2;
224 if (new_capacity < min_sz) {
225 new_capacity = min_sz;
226 }
227 T* elms = static_cast<T*>(malloc(new_capacity * sizeof(T)));
228
229 this->uninitialized_move(this->begin(), this->end(), elms);
230
231 this->destroy_range(this->begin(), this->end());
232
233 if (!this->is_small()) {
234 free(this->begin());
235 }
236
237 this->m_begin_ptr = elms;
238 this->set_end(elms + cur_sz);
239 this->m_capacity_ptr = this->begin() + new_capacity;
240}
241
242template <typename T>
243class SmallVectorTemplateBase<T, true> : public SmallVectorTemplateCommon<T> {

Callers 9

push_backMethod · 0.95
resizeMethod · 0.45
reserveMethod · 0.45
appendMethod · 0.45
assignMethod · 0.45
insertMethod · 0.45
emplace_backMethod · 0.45
swapMethod · 0.45
small_vector.hFile · 0.45

Calls 9

uninitialized_moveMethod · 0.95
destroy_rangeMethod · 0.95
freeFunction · 0.85
capacityMethod · 0.80
is_smallMethod · 0.80
set_endMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected