[RFC] Vector (string?) growth factor of 1.5 (insted of 2)

Paolo Carlini pcarlini@suse.de
Mon Feb 2 18:32:00 GMT 2004


Gabriel Dos Reis wrote:

> "Bo Persson" <bop@gmb.dk> writes:
>
> | I think we should not only measure speed, but also consider the 
> amount of
> | memory wasted by over allocation.
> |
> | If you want maximum speed for a particular container, you should of 
> course
> | allocate every single byte available for it at once, and be done 
> with it.
>
> I agree.

Well, I also agree, in principle.... This would favor smaller growth 
factors...

However, consider the constructor from input iterators that I have "fixed"
recently to finally use the exponential growth policy which we had 
available:
in such cases it makes little sense talking of "allocate at once", since, in
general, you cannot know in advance how big is the string that you are going
to construct (yes, you could pre-allocate all of your real + virtual 
memory...
you get the point, I think...)

Paolo.



More information about the Libstdc++ mailing list