[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Filling multiple tables in one loop
- From: Thijs Schreijer <thijs@...>
- Date: Sat, 18 May 2013 14:07:11 +0000
> lua_pushnumber(L, data[i]); // Push the data element
> lua_rawseti(L, -3, i + 1); // firstTable[i+1] = data[i]
>
> // if data[i] > min and < max, I want to add it to a second result
> table
> if(data[i] > min && data[i] < max) {
> lua_pushnumber(L, data[i]); // Push the data element
> lua_rawseti(L, -2, i+1); // secondTable[i+1] = data[i]
> }
> }
Wouldn't it be cheaper to perform the min/max test first, and then duplicate the element on the stack (lua_pushvalue) instead of calling lua_pushnumber twice? (with 10000 elements that should be easy to test)
Thijs