This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Fwd: basic_string<> - useless because of its poor performance]
Loren James Rittle wrote:
> Ryszard Kabatek <Ryszard.Kabatek@softax.pl> writes:
>
> > The current implementation of basic_string is too slow to be useful.
>
> Only if you fail to use reserve() wisely as suggested by Stroustrup... ;-)
No. The standard says that string growth is "amortized linear".
> I do basically agree that we should do something better than
> per-character growth given what we generally know about malloc
> implementations. However, it is unclear that an exponential growth
> policy is wise.
An exponential growth policy is the only way to get the performance
required by the standard. In fact, exponential growth with base 2
is required by the wording, although there have been suggestions that
1.5 should be allowed in future amendments.
Nathan Myers
ncm at cantrip dot org