4 ms·
Oh! So the string itself is still on the heap? I assumed it was all on the stack.
by tomcam 2y ago
Oh! So the string itself is still on the heap? I assumed it was all on the stack.
- super_flanker 2y agoNo, let me try to explain differently. If `compact_str` was not used, then your normal `String` would take 24 bytes of stack space (regardless of the string size) + heap space. What `compact_str` is trying to do is not use heap when string content is less than 24.
- tomcam 2y agoThank you. That aligns with what I originally thought.