[libmath-prime-util-perl] 27/43: Move a big hash to closure instead of sub local

Partha P. Mukherjee ppm-guest at moszumanska.debian.org
Thu May 21 18:53:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.40
in repository libmath-prime-util-perl.

commit 175ee9baab39956807f43f65eae6e60bf4a0610d
Author: Dana Jacobsen <dana at acm.org>
Date:   Thu Apr 3 11:45:09 2014 -0700

    Move a big hash to closure instead of sub local
---
 bin/primes.pl | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/bin/primes.pl b/bin/primes.pl
index 24e536e..3818cb8 100755
--- a/bin/primes.pl
+++ b/bin/primes.pl
@@ -543,11 +543,8 @@ sub gen_and_filter {
   $p;
 }
 
-sub find_mod210_restriction {
-  my %mods_left;
-  undef @mods_left{ grep { ($_%2) && ($_%3) && ($_%5) && ($_%7) } (0..209) };
-  
-  my %mod210_restrict = (
+{
+  my %_mod210_restrict = (
     cuban1     => {min=> 7, mod=>[1,19,37,61,79,121,127,169,187]},
     cuban2     => {min=> 2, mod=>[1,13,43,109,139,151,169,181,193]},
     twin       => {min=> 5, mod=>[11,17,29,41,59,71,101,107,137,149,167,179,191,197,209]},
@@ -561,17 +558,22 @@ sub find_mod210_restriction {
     # Nothing for good, pillai, palindromic, fib, lucas, mersenne, primorials
   );
 
-  my $min = 0;
-  while (my($filter,$data) = each %mod210_restrict) {
-    next unless exists $opts{$filter};
-    $min = $data->{min} if $min < $data->{min};
-    my %thismod;
-    undef @thismod{ @{$data->{mod}} };
-    foreach my $m (keys %mods_left) {
-      delete $mods_left{$m} unless exists $thismod{$m};
+  sub find_mod210_restriction {
+    my %mods_left;
+    undef @mods_left{ grep { ($_%2) && ($_%3) && ($_%5) && ($_%7) } (0..209) };
+  
+    my $min = 0;
+    while (my($filter,$data) = each %_mod210_restrict) {
+      next unless exists $opts{$filter};
+      $min = $data->{min} if $min < $data->{min};
+      my %thismod;
+      undef @thismod{ @{$data->{mod}} };
+      foreach my $m (keys %mods_left) {
+        delete $mods_left{$m} unless exists $thismod{$m};
+      }
     }
+    return ($min, %mods_left);
   }
-  return ($min, %mods_left);
 }
 
 # This is rather braindead.  We're going to eval their input so they can give

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git



More information about the Pkg-perl-cvs-commits mailing list