logoalt Hacker News

ranger_dangerlast Saturday at 2:52 AM1 replyview on HN

I was basing my response off of this:

> i did see a place to shave a byte in the sds data struct. The null terminator is a wasted field

I'm still not sure what byte in the struct you're talking about removing... because I don't see an actual null terminator field.


Replies

fsckboylast Saturday at 4:11 AM

the word "null term" appears in the ascii art diagram, that's where the null terminator is. the strlen field is in the portion labelled header.

the strlen field can be moved to where the word "null term" appears, except with a changed semantic of "bytes remaining" so it will go to zero at the right time. now you have a single entity "bytes remaining" instead of two entities, "strlen" and "null" giving a small storage saving (there is an additional null terminator most of the time, right at the end of the string; but this doesn't take up any storage because that storage is not used for anything else)

over and out.

show 1 reply