ruby-changes:38722
From: marcandre <ko1@a...>
Date: Tue, 9 Jun 2015 12:32:52 +0900 (JST)
Subject: [ruby-changes:38722] marcandRe: r50803 (trunk): * lib/prime.rb: Simplify and optimize EratosthenesSieve
marcandre 2015-06-09 12:32:45 +0900 (Tue, 09 Jun 2015) New Revision: 50803 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50803 Log: * lib/prime.rb: Simplify and optimize EratosthenesSieve Modified files: trunk/ChangeLog trunk/lib/prime.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 50802) +++ ChangeLog (revision 50803) @@ -1,6 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jun 9 12:31:25 2015 Marc-Andre Lafortune <ruby-core@m...> + + * lib/prime.rb: Simplify and optimize EratosthenesSieve + Tue Jun 9 11:45:00 2015 Marc-Andre Lafortune <ruby-core@m...> - * lib/matrix.rb: Simplify and optimize EratosthenesSieve + * lib/prime.rb: Simplify and optimize EratosthenesSieve based on patch by Ajay Kumar. [Fixes GH-921] Mon Jun 8 05:09:58 2015 Koichi Sasada <ko1@a...> Index: lib/prime.rb =================================================================== --- lib/prime.rb (revision 50802) +++ lib/prime.rb (revision 50803) @@ -436,9 +436,8 @@ class Prime https://github.com/ruby/ruby/blob/trunk/lib/prime.rb#L436 end end - segment.each do |prime| - @primes.push prime unless prime.nil? - end + @primes.concat(segment.compact!) + @max_checked = segment_max end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/