Re:Designing a better strcpy
by codesnik on Saturday June 19, 2021 @06:23PM
(#27565044)
you can also have something akin to MIDI encoding with higher bit reserved to mark that next byte is a part of length field, too. up to 128 bytes with no overhead, up to 16kb with one byte overhead, and so on. Such a detail would be easy to hide in the library. But I wouldn't be surprised that alignment and other troubles would eat any possible gain.
[ Parent
| on HN ]
> But I wouldn't be surprised that alignment ... troubles would eat any possible gain.
It's string. Alignment shouldn't be a problem. Rather alignment issues are for the pointers to that string.
Re:Designing a better strcpy
by WalterBright on Saturday June 19, 2021 @06:45PM
(#27565203)
Won't work with UTF-8.
Re:Designing a better strcpy
by thrwaeasddsaf on Saturday June 19, 2021 @07:49PM
(#27565650)
Works with any encoding and arbitrary binary data. The last byte of the length field doesn't have the high bit set, and whatever follows after that is completely irrelevant.
But still needless complexity for this.