[Patch] libstdc++/16612
Paolo Carlini
pcarlini@suse.de
Tue Sep 28 17:04:00 GMT 2004
Benjamin Kosnik wrote:
>I guess I'm still not sure why this is conditional. Can you explain your
>reasoning here? I don't see the _S_empty_rep checks as being necessary
>for correctness or performance. What am I missing?
>
>
Indeed, _S_empty_rep is not necessary for correctness, is an optimization.
However, when general applications are concerned (not using shared
memory, that is), is definitely a *good* optimization. In order to
appreciate that just construct a testcase involving lots of
default-constructed strings... Thanks to _S_empty_rep, slow, unnecessary
allocation of dynamic memory is delayed 'til really necessary.
The proper fix, in my opinion, involves storing short strings in the
string object itself (that is, both the empty string, consisting only of
charT() and also larger strings up to, say, 8-16 chars), without using
dynamic memory (and its slowness), neither static memory (and its
problems vs 16612). I'm working on that, seems feasible in a reasonable
amount of time.
That said, perhaps we can add tricks to 3.4/4.0 helping the performance
when lots of default constructed strings are involved, we'll see soon
what we can do in this area too... In that case,
--enable-fully-dynamic-string will go, and we'll be all happier! But
frankly I doubt that we can really achieve that within the 3.4/4.0 ABI,
would too good to be true...
Paolo.
More information about the Libstdc++
mailing list