Comment on Never create Ruby strings longer than 23 charactersparentComments−throw_away14yThey probably are when they are inlined like this, else, how would you know the length?−charliesome14yThe length is stored in a flag.include/ruby/ruby.h: #define RSTRING_EMBED_LEN(str) \ (long)((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \ (RSTRING_EMBED_LEN_MASK >> RSTRING_EMBED_LEN_SHIFT)) #define RSTRING_LEN(str) \ (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \ RSTRING_EMBED_LEN(str) : \ RSTRING(str)->as.heap.len)
Comments
They probably are when they are inlined like this, else, how would you know the length?
The length is stored in a flag.
include/ruby/ruby.h: