Comment by chrismorgan
13 hours ago
There are two differences.
① A growable string type overallocates, so you only eventually need to reallocate. An immutable string type has an exact-size allocation, so you must make a new allocation every time.
② An immutable string type can’t use realloc() anyway unless you can prove nothing else holds a reference to it, it needs to use a new malloc().
No comments yet
Contribute on Hacker News ↗