2 ms·
How is iterating over the string each time you want to do anything meaningful better? Also, there is a short string optimization, where you can store the string
by kaba0 5y ago
How is iterating over the string each time you want to do anything meaningful better? Also, there is a short string optimization, where you can store the string inside the pointer , eg. c++ does just that.
- jstimpfle 5y agoYou didn't read my comment right. My statement is there isn't one true string type. I didn't say you shouldn't use a length field. Zero terminated strings still make some sense of course - ease of reading when looking at byte level representation, and moderate cost savings in packed structs (4, 8, or 16 byte strings). The former is why I zero terminate by default where possible, even when using a separate length field stored somewhere else (almost always).