3 ms·
> This will cause a lot of indirect access You can optimize the common case of string data following the header by encoding the fact in a bit of the length fie
by ithkuil 4y ago
> This will cause a lot of indirect access
You can optimize the common case of string data following the header by encoding the fact in a bit of the length field.
E.g. if the length is odd (LSB = 1) then the next word contains the pointer to the string body, otherwise the string body follows the length field. Archs that lack tagged arithmetic would require a shift but at least that skips a memory read for the string data indirection.