In prevector.h, the code which like item_ptr(size())
apears in the loop.
Both item_ptr()
and size()
judge whether values are held directly or
indirectly, but in most cases it is sufficient to make that judgement
once outside the loop.
This PR adds 2 private function fill()
which has the loop to initialize
by specified value (or iterator of the other prevector’s element),
but don’t call item_ptr()
in their loop.
Other functions(assign()
, constructor
, operator=()
, insert()
)
that has similar loop, call fill()
instead of original loop.
Also, resize()
was changed like fill()
, but it calls the default
constructor for that element each time.