2 ms·
Copying is almost always the right answer here. - you can't assume inline storage of the substring, which is more efficient, because that'd mean overwriting th
by astrange 5y ago
Copying is almost always the right answer here.
- you can't assume inline storage of the substring, which is more efficient, because that'd mean overwriting the parent string with a size field
- you might free the parent string early unless you keep around a reference to it, which is more expensive
- usually strings (esp. substrings) aren't that long, and for very long ones you can use a different data structure