lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



 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);
Compilers nowadays won't call strlen for string literals: https://godbolt.org/z/s996MT

Don't assume, test, measure, look at the compiler's output.

Andre Leiradella