some basic_string optimization
Nathan Myers
ncm@cantrip.org
Fri Apr 28 13:45:00 GMT 2000
On Fri, Apr 28, 2000 at 07:14:32PM +0400, Vadim Egorov wrote:
> I found that replacing a single character in a string was a bit more
> expensive than I thought. Making _M_mutate call conditional made
> this operation work seems improves the situation.
> ...
> diff -c -r1.59 string.tcc
> *** string.tcc 2000/03/28 04:21:42 1.59
> --- string.tcc 2000/04/28 14:30:36
> ***************
> *** 440,446 ****
> ! _M_mutate(__off, __dold, __dnew);
> --- 440,447 ----
> ! if (__dold != __dnew)
> ! _M_mutate(__off, __dold, __dnew);
I think this doesn't work. You must also check that the
string representation isn't shared with any other string
object; see the definition of _M_mutate, and the non-const
operator[]. Is there some reason you're not using operator[]?
Nathan Myers
ncm at cantrip dot org
More information about the Libstdc++
mailing list