Subject: | Primes() not mark i=composite for less work |
Date: | Sat, 06 Nov 2010 07:40:41 +1100 |
To: | bug-Bit-Vector [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
Nosing around the code of Bit::Vector 7.1 BitVector_Primes(), as an
optimization I wonder if the "j" loop doing BIT_VECTOR_CLR_BIT() can be
skipped when i=composite. Eg. multiples of i=15 don't have to be marked
as they're already covered by previous i=3 or i=5.
Marking only primes found thus far is fairly usual I think. I suppose
it'd be a check BIT_VECTOR_TST_BIT(addr,i) and ought to save a good bit
of work.