On Friday 22 June 2007 09:30:40 Mark Glines wrote: > > If we're passing in a string literal, it seems silly to pass in a > > length of 0, as we're recalculating a constant on every call. I > > don't see that this macro fixes that.
> It uses sizeof, not strlen. So, it pushes the calculation to > compile-time, so you only have to do it once, and never at runtime. > Also, using sizeof() will fix some cases that strlen() doesn't handle > correctly, specifically, strings containing explicit null characters. > src/objects.c has a few examples of that. string_to_cstring(interp, > "\0", 0) will get the size wrong, but string_to_cstring_literal(interp, > "\0") will get it right. So I don't really see a good excuse for not > using it everywhere. You and Nicholas are both right. I saw sizeof() but thought strlen(). With Patrick's suggestion to use the name string_from_literal() instead, I'm satisfied. -- c