3 ms·
That assumes that the string characters are not adjacent to the string length field in memory... (Edited to add) More explicitly: Grandparent specified length-
by colomon 15y ago
That assumes that the string characters are not adjacent to the string length field in memory...
(Edited to add) More explicitly: Grandparent specified length-prefix strings, where the string's length is stored in memory immediately before the string's characters. And his claim is correct in that case.
You seem to be assuming a string object which consists of a length and a pointer to the characters. What you suggest certainly would work there, but any straight-forward implementation of this is going to require another pointer's worth of memory and two memory allocations for each string, too.