A nil upvalue makes lua_objlen stop counting leaving following upvalues nil as well
instead explicitly store ar.nups when the table is created
lmarshal.c#L224
lua_newtable(L);
for (i=1; i <= ar.nups; i++) {
lua_getupvalue(L, -2, i);
lua_rawseti(L, -2, i);
}
should become
lua_createtable(L, ar.nups, 1);
lua_pushinteger(L, ar.nups);
lua_setfield(L, -2, "nups");
for (i=1; i <= ar.nups; i++) {
lua_getupvalue(L, -2, i);
lua_rawseti(L, -2, i);
}
lmarshal.c#L389
mar_decode_table(L, *p, l, idx);
nups = lua_objlen(L, -1);
for (i=1; i <= nups; i++) {
lua_rawgeti(L, -1, i);
lua_setupvalue(L, -3, i);
}
should become
mar_decode_table(L, ld_lpf, field.v_len, idx);
lua_getfield(L, -1, "nups");
nups = lua_tointeger(L, -1);
lua_pop(L, 1);
for (i=1; i <= nups; i++) {
lua_rawgeti(L, -1, i);
lua_setupvalue(L, -3, i);
}
A nil upvalue makes lua_objlen stop counting leaving following upvalues nil as well
instead explicitly store ar.nups when the table is created
lmarshal.c#L224
lua_newtable(L);for (i=1; i <= ar.nups; i++) {lua_getupvalue(L, -2, i);lua_rawseti(L, -2, i);}should become
lua_createtable(L, ar.nups, 1);lua_pushinteger(L, ar.nups);lua_setfield(L, -2, "nups");for (i=1; i <= ar.nups; i++) {lua_getupvalue(L, -2, i);lua_rawseti(L, -2, i);}lmarshal.c#L389
mar_decode_table(L, *p, l, idx);nups = lua_objlen(L, -1);for (i=1; i <= nups; i++) {lua_rawgeti(L, -1, i);lua_setupvalue(L, -3, i);}should become
mar_decode_table(L, ld_lpf, field.v_len, idx);lua_getfield(L, -1, "nups");nups = lua_tointeger(L, -1);lua_pop(L, 1);for (i=1; i <= nups; i++) {lua_rawgeti(L, -1, i);lua_setupvalue(L, -3, i);}