Skip to content

ATLASRECTS-7536: Try to retain capacity of the vectors so as to reduce allocations

ATLASRECTS-7536: Try to retain capacity of the vectors so as to reduce allocations

This is more or less a variant of



for ( ... ) {
   std::vector<foo> V;
   // make use of V.
}

Instead, write this as:

std::vector<foo> V;
for ( ... ) {
   // make use of V.
   V.clear();
}

The type we have is a bit clunky , but at the end we want to retain the capacity of the inner vectors. The outer vector we could replace with array if we know the max but this is for another day .

So we clear the inner ones, and resize so as to be default init to false, but clean and resize should not reduce capacity so we should be gaining allocation/re-allocations .

ping @sroe

Edited by Christos Anastopoulos

Merge request reports

Loading