[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Filling multiple tables in one loop
- From: Thijs Schreijer <thijs@...>
- Date: Sat, 18 May 2013 14:45:46 +0000
> -----Original Message-----
> From: Bas Groothedde [mailto:email@example.com]
> Sent: zaterdag 18 mei 2013 16:34
> To: Thijs Schreijer
> Subject: RE: Filling multiple tables in one loop
> On 18.05.2013 16:07, Thijs Schreijer wrote:
> > 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)
> That's a very good point, but the actual function I want to apply this to
> is a prime sieve function, the Sieve of Eratosthenes.
> This specific siever that fills two tables, fills one table with prime
> numbers within the range, and the other table is a lookup
> table where i is a number and v is a boolean stating if i is a prime.
> This means that table one consists of numbers and table two consists of
> booleans, would pushvalue be useful in this situation?
In that case no, because lua_pushvalue duplicates a value already on the stack. And as you need two different values, it won't help you speed things up.