News for hackers. Stuff that matters.
Re:Never create Ruby strings longer than 23 characters by gesman on Wednesday December 11, 2013 @11:11AM (#6888328)
I wonder why they didn't make cut-off optimization points at 33?

When programmers don't know in advance how long name/email/input/whatever field is going to be - they just use the magic "power of two" length :)

So 32 (or 33) in this case would be more reasonable.

Re:Never create Ruby strings longer than 23 characters by gliese1337 on Wednesday December 11, 2013 @11:30AM (#6888480)
Because of this line:

    #define RSTRING_EMBED_LEN_MAX ((int)((sizeof(VALUE)*3)/sizeof(char)-1))
23 wasn't chosen, it was calculated to be the size that would be required for a struct describing a heap string, and will actually be a different number for different architectures. Choosing to make it bigger would add unnecessary overhead to the RString struct.
Re:Never create Ruby strings longer than 23 characters by njharman on Wednesday December 11, 2013 @11:30AM (#6888477)
> When programmers don't know

They did know. And there are many more cutoffs than powers of two, depending on storage backend.