3 ms·
I mean a variable-length array, all stored together. Presumably you'd allocate it on the heap in general. But a record string also requires a heap allocation.
by Dylan16807 8y ago
I mean a variable-length array, all stored together.
Presumably you'd allocate it on the heap in general. But a record string also requires a heap allocation.
Most of the time you're touching the length you're probably touching the string data too, so that dereference isn't going to cost very much. And it comes with a tradeoff of more compact local data. So I stand by it being not awful! It may not be perfect, but it's a solid option.
- Thiez 8y agoWhen you have record strings you get slicing for free though. Without the indirection of a pointer you have to copy data when you slice (or you must have a separate 'sliced string' type).
- Dylan16807 8y ago"free" if you ignore the cost of doing lifetime management. So beneficial in some use cases but not others.