std::string responsible for half the allocations in chrome

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 5 14:17:16 PST 2014


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).


T

-- 
Music critic: "That's an imitation fugue!"


More information about the Digitalmars-d mailing list