3 ms·
A relatively common implementation of strings (as compared to slices) is to store the length before the char array. The length field can be encoded with a varia
by gpderetta 11y ago
A relatively common implementation of strings (as compared to slices) is to store the length before the char array. The length field can be encoded with a variable size encoding. The string itself is just a single pointer.
If you have a real garbage collector of course using the same representation for strings and slices (two pointers or pointer+len) is appropriate.