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]

[RFC] string: exponential growth inside _S_create?!?


Hi,

this is an interesting issue about which I'd really appreciate having
some feedback from all the people involved (in particular, Nathan and
Loren).

Currently, the exponential growth policy mandated by the standard is
duplicated inside both _M_mutate and _M_clone. The latter, in turn,
call _S_create, which rounds to a malloc-friendly size and actually
allocates memory.

Besides the duplication and all the redundant computations, what really
prompt me to ask your feedback is this issue: the constructor for
input_iterators does its hard job by repeatedly calling _S_create in
a loop, each time requesting space for one character more.

This means that it doesn't exploit any form of exponential grow policy!

From a practical point of view, I don't know for sure if this is the
bottleneck for a fast constructor from input iterators... on the other
hand, certainly we don't want to *triplicate* the exponential grow policy!!

So... Shall I try to implement it *inside* _S_create?

It seems to me that, in case of success, this would allow a major
clean-up, better incapsulation, better performance (?) for the constructor
from input iterators.

What do you think?

Thanks in advance,
Paolo.


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