Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: