[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Sieve of Eratosthenes performance question
- From: roberto@... (Roberto Ierusalimschy)
- Date: Wed, 6 Jun 2007 09:33:35 -0300
> I believe the difference is because I made 'composite' an array with
> contiguous numerical indexes, with optimized access in Lua 5.1 (direct
> offset computing), while in the previous code, Lua probably has to make
> more complex tests (hashing the index?) to see if the slot is empty.
This is my guess, too. You can check by initializing the "prime" array
with falses before starting the sieve (as you do with 'composite').