When std :: vector needs to be redistributed, it increases its distribution size by N * 2, where n is its current size. This results in a logarithmic number of reallocs as the vector grows.
If instead std :: vector increased its allocated space by a constant value, the number of overruns would increase linearly with the growth of the vector.
What you did essentially results in the vector growing at a constant value of 3, which means linear growth. Linear is obviously worse than logarithmic, especially with large numbers.
As a rule, the only growth other than logarithmic is constant. This is why the standards committee created a backup method. If you can avoid all reallocs (constants), you will work better than the default logarithmic behavior.
However, you might think of Herb Sutter's comments that you prefer std :: deque over vector www.gotw.ca/gotw/054.htm
deft_code
source share