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)


Gabriel Dos Reis wrote:

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.

Ok. I think that, by and large, we already do our best, both in string and in vector...

A detail comes to my mind, though: perhaps, at construction time,
speed matters more and, in the case of the constructor from input
iterators, we should allow for a bigger factor. Later, memory usage
matters more and a smaller factor seem in order (-> as you say, if
the max speed is really needed reserve is always available, then).

Perhaps (perhaps), we should parameterize _S_create and call it
differently. Similarly for vector...

Hummmm

Paolo.

P.S.: there is a minor twist, which makes string slightly different
from vector: for the former is really trivial a shrink to fit
(reserve(0)), whereas for vector the slightly less intuitive trick
described in the docs (pointed out by Nathan) is necessary.


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