Live data from Hacker News

Chromium: Substring of string retains string in memory

issues.chromium.org

1–4 of 4 posts

Re: Chromium: Substring of string retains string in memory

#3
This seems like the string version of --ffast-math. Optimize performance at the cost of everything else[1]. Except with --fast-math you explicitly turn it on.

I assume the underlying storage isn't reference counted, because if it was it seems it would be trivial to detect there's only a single reference left, and trigger a reallocation.

[1]: https://gcc.gnu.org/wiki/FloatingPointMath

Re: Chromium: Substring of string retains string in memory

#4

This seems like the string version of --ffast-math. Optimize performance at the cost of everything else[1]. Except with --fast-math you explicitly turn it on. I assume the underlying storage isn't reference counted, because if it was it seems it would be trivial to detect there's only a single reference left, and trigger a reallocation. [1]: https://gcc.gnu.org/wiki/FloatingPointMath

But having only one reference is rare, often you extract several pieces of data from a huge string.

Unless the underlying storage is reference counted with some small granularity. That might be a way to go, when a substring is taken, split the original and keep track of the pieces separately.