[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/04: c/r-html-reports: Scope a map to reuse memory



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

nthykier pushed a commit to branch master
in repository lintian.

commit 003f95ea74542ebbb33483b7353e4cdf317e6917
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Jul 6 20:31:26 2017 +0000

    c/r-html-reports: Scope a map to reuse memory
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 commands/reporting-html-reports.pm | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/commands/reporting-html-reports.pm b/commands/reporting-html-reports.pm
index 4d663e2..5cf2e2e 100644
--- a/commands/reporting-html-reports.pm
+++ b/commands/reporting-html-reports.pm
@@ -820,7 +820,7 @@ sub parse_lintian_log {
     # The "last_*" are optimizations to avoid computing the same
     # things over and over again when a package have multiple tags.
     my (%seen, $last_info, $last_maintainer, %unknown_member_id, $info,
-        $last_pi);
+        $last_pi, %map_maint);
     my %expanded_code = (
         E => 'errors',
         W => 'warnings',
@@ -953,7 +953,8 @@ sub parse_lintian_log {
             # and, if so, map them to the same person as the previous
             # one.
 
-            $last_maintainer = $maintainer = map_maintainer($maintainer);
+            $last_maintainer = $maintainer
+              = map_maintainer(\%map_maint, $maintainer);
 
             # Update maintainer statistics.
             $statistics{maintainers}++ unless defined $by_maint{$maintainer};
@@ -995,7 +996,7 @@ sub parse_lintian_log {
                             # d/control for some uploaders.
                             $uploader =~ s/^"(.*)" <(.*)>$/$1 <$2>/;
                         }
-                        $uploader = map_maintainer($uploader);
+                        $uploader = map_maintainer(\%map_maint, $uploader);
                         next if $uploader eq $maintainer;
                         $by_uploader{$uploader}{$source}{$source_version}
                           = $list_ref;
@@ -1015,24 +1016,15 @@ sub parse_lintian_log {
 # Deduplicate maintainers.  Maintains a cache of the maintainers we've seen
 # with a given e-mail address and returns the maintainer string that we
 # should use (which is whatever maintainer we saw first with that e-mail).
-
-# PerlCritic apparently does not recognise this way of "encapsulating"
-# variables.  Though, these could probably be replaced by "state"
-# variables.
-## no critic (ControlStructures::ProhibitUnreachableCode)
-{
-    my (%urlmap);
-
-    sub map_maintainer {
-        my ($maintainer) = @_;
-        my $url = maintainer_url($maintainer);
-        if ($urlmap{$url} && $urlmap{$url} ne $maintainer) {
-            $maintainer = $urlmap{$url};
-        } else {
-            $urlmap{$url} = $maintainer;
-        }
-        return $maintainer;
+sub map_maintainer {
+    my ($urlmap, $maintainer) = @_;
+    my $url = maintainer_url($maintainer);
+    if ($urlmap->{$url} && $urlmap->{$url} ne $maintainer) {
+        $maintainer = $urlmap->{$url};
+    } else {
+        $urlmap->{$url} = $maintainer;
     }
+    return $maintainer;
 }
 
 # Quote special characters for HTML output.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: