News for hackers. Stuff that matters.
Re:Never create Ruby strings longer than 23 characters by Sharlin on Wednesday December 11, 2013 @10:54AM (#6888214)
The small string buffer should be the same size as the "heap" struct so as not to waste memory -- remember, they shared the memory as they're members of a union. The heap struct contains three members which, taking into accoult alignment restrictions, usually add up to three times the machine word size (which is basically what sizeof(uintptr_t) is). The "-1" is because C strings are null-terminated, so the maximum length is one less than the size of the buffer.

What I don't know is why they don't simply use sizeof(heap) as the buffer size.

Re:Never create Ruby strings longer than 23 characters by grosbisou on Wednesday December 11, 2013 @11:55AM (#6888723)
Ah that was obvious. Thanks, very clear answer.