Revamp of 'lua_pushfstring' / 'luaO_pushvfstring'

The function 'luaO_pushvfstring' now uses an internal buffer to
concatenate small strings, instead of pushing all pieces on the
stack. This avoids the creation of several small Lua strings for each
piece of the result. (For instance, a format like "n: '%d'" used to
create three intermediate strings: "n: '", the numeral, and "'".
Now it creates none.)
This commit is contained in:
Roberto Ierusalimschy
2019-04-24 14:01:20 -03:00
parent 20b161e285
commit 3da34a5fa7
4 changed files with 177 additions and 44 deletions

View File

@@ -1481,6 +1481,15 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
else if EQ("pushvalue") {
lua_pushvalue(L1, getindex);
}
else if EQ("pushfstringI") {
lua_pushfstring(L1, lua_tostring(L, -2), (int)lua_tointeger(L, -1));
}
else if EQ("pushfstringS") {
lua_pushfstring(L1, lua_tostring(L, -2), lua_tostring(L, -1));
}
else if EQ("pushfstringP") {
lua_pushfstring(L1, lua_tostring(L, -2), lua_topointer(L, -1));
}
else if EQ("rawgeti") {
int t = getindex;
lua_rawgeti(L1, t, getnum);