> anyway, usage of lua_pushlstring instead of lua_pushstring is much better.
For literal strings, lua_pushstring is both simpler to use and faster.
lua_pushstring(L, "cannot close standard file");
Can be simpler, but it is not faster than:
/* avoid strlen call or inline */
lua_pushlstring(L, "cannot close standard file", sizeof("cannot close standard file") - 1);
Another example:
void luaT_init (lua_State *L) {
static const char *const luaT_eventname[] = { /* ORDER TM */
"__index", "__newindex",
"__gc", "__mode", "__len", "__eq",
"__add", "__sub", "__mul", "__mod", "__pow",
"__div", "__idiv",
"__band", "__bor", "__bxor", "__shl", "__shr",
"__unm", "__bnot", "__lt", "__le",
"__concat", "__call", "__close"
};
unsigned int i;
for (i=0; i<TM_N; ++i) {
G(L)->tmname[i] = luaS_newlstr(L, luaT_eventname[i], sizeof(luaT_eventname[i]) - 1); /* build-time size */