std::string responsible for half the allocations in chrome

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 19 18:14:36 PST 2014


On 12/5/14 2:17 PM, H. S. Teoh via Digitalmars-d wrote:
> On Fri, Dec 05, 2014 at 10:03:38PM +0000, deadalnix via Digitalmars-d wrote:
>> http://www.reddit.com/r/programming/comments/2ocmvb/stdstring_is_responsible_for_almost_half_of_all/
>>
>> Looks like someone need immutable(char)[] .
>
> Yeah!!! String processing totally sucks in C/C++, even with clever
> tricks like ropes for std::string.
>
> Having said that, though, D's immutable(char)[] isn't panacea either.
> I've seen (well, written... *hangs head in shame*) D code that deals
> with const(char)[] and needs to produce string, and as a result is a bit
> too trigger-happy with .idup's. Causes lots of GC slowdown. It used to
> be that you could just grep for idup to find the problem spots, but
> nowadays with the to!string idiom, many of these idups could be masked
> behind a nice to!string (which is harmless if the source is already
> string, but it's not always immediately obvious at a glance).

RCString is the solution. http://dpaste.dzfl.pl/817283c163f5 -- Andrei



More information about the Digitalmars-d mailing list