Hacker News new | ask | show | jobs
by burnt-resistor 16 days ago
Another string length O(1) encoding format like Pascal strings that were len (unsigned byte) + data. Limited to 255 characters however.

Dollar, NUL, and other terminated strings, by contrast, are string length O(N).

2 comments

fast cgi has a good one, length then binary follows, if the length is 127 or less, the length is contained within one byte, if not the length is contained in 4 bytes, then the data follows. Midi has a similar scheme for representing some numbers, the high order bit denotes if there's another byte of the number following or something like that lol
strlen for netstring is O(log n).