[PATCH] _M_replace (take3): better clean up + speed ups!!
Paolo Carlini
pcarlini@unitus.it
Mon Dec 10 00:34:00 GMT 2001
Benjamin Kosnik wrote:
> Hey Paolo. This looks good.
>
> > mainline
> > --------
> > Execution time of 100000 string::append(const string&) calls: 0.09 sec. <----
> > Execution time of 1000000 string::append(const string&) calls: 0.86 sec. <----
> > Execution time of 10000000 string::append(const string&) calls: 8.59 sec. <----
> >
> > mainline + this patch
> > ---------------------
> > Execution time of 100000 string::append(const string&) calls: 0.05 sec. <----
> > Execution time of 1000000 string::append(const string&) calls: 0.35 sec. <----
> > Execution time of 10000000 string::append(const string&) calls: 3.56 sec. <----
> >
> > 2.95.3
> > ------
> > Execution time of 100000 string::append(const string&) calls: 0.05 sec. <----
> > Execution time of 1000000 string::append(const string&) calls: 0.35 sec. <----
> > Execution time of 10000000 string::append(const string&) calls: 3.55 sec. <----
>
> So, with this patch, the last of the performance regressions WRT
> std::string between v2 and v3 is fixed? That would be great.
Almost ;-)
There is still a very minor slowdown for const char*, in fact. And of course v3 is better
than v2 as far as correctness is concerned (see, f.i., PR4354).
And this is only the beginning: I find Nathan's ideas about improving the performance in
special cases very stimulating and I think that very soon, v3 could be *faster* than v2
in such cases.
> > 2001-12-09 Paolo Carlini <pcarlini@unitus.it>
> > Nathan Myers <ncm@cantrip.org>
> >
> > * include/bits/basic_string.tcc (_M_replace_safe): New.
> > * include/bits/basic_string.tcc (_M_replace(input_iterator_tag),
> > append members): use it.
> > * include/bits/basic_string.tcc (_M_replace(forward_iterator_tag)): Remove.
> > * include/bits/basic_string.h: Adjust declarations.
>
> You can just list basic_string.tcc once.
Ok.
> Is there anyway you can add some documentation for this? That would be
> much appreciated.
For the time being I will put some comments in the code. Thanks for quick reviewing!
Cheers,
Paolo.
More information about the Libstdc++
mailing list