This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Paolo Carlini <pcarlini@suse.de> writes:

| 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...)

if the only thing you have  is a genuine input iterator you're
effectively stuck.  However, if you have at least a bidirectional
iterator, then you can have an idea of the amount staorage you need.
We already have dispatchers that compute those iterator categories.
It might be a good idea to take advantage of them.

-- Gaby


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]