pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/pkgtools/pkglint/files Optimized the doc/CHANGES handl...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e74efa49b4de
branches:  trunk
changeset: 392126:e74efa49b4de
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Apr 26 12:51:35 2009 +0000

description:
Optimized the doc/CHANGES handling to get the get_doc_CHANGES function
out of the top-15 time consumers, as measured by DProf. The execution
time decreased by about 15 percent.

diffstat:

 pkgtools/pkglint/files/pkglint.pl |  24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diffs (62 lines):

diff -r fd29f092537f -r e74efa49b4de pkgtools/pkglint/files/pkglint.pl
--- a/pkgtools/pkglint/files/pkglint.pl Sun Apr 26 11:43:44 2009 +0000
+++ b/pkgtools/pkglint/files/pkglint.pl Sun Apr 26 12:51:35 2009 +0000
@@ -1,5 +1,5 @@
 #! @PERL@
-# $NetBSD: pkglint.pl,v 1.809 2009/04/26 11:24:23 rillig Exp $
+# $NetBSD: pkglint.pl,v 1.810 2009/04/26 12:51:35 rillig Exp $
 #
 
 # pkglint - static analyzer and checker for pkgsrc packages
@@ -2189,21 +2189,21 @@
        my ($fname) = @_;
        my $lines = load_file($fname) or die;
 
-       my @changes = ();
+       my $changes = {}; # { pkgpath -> @changes }
        foreach my $line (@$lines) {
                my $text = $line->text;
                next unless $text =~ m"^\t[A-Z]";
 
                if ($text =~ m"^\t(Updated) (\S+) to (\S+) \[(\S+) (\d\d\d\d-\d\d-\d\d)\]$") {
-                       push(@changes, PkgLint::Change->new($line, $1, $2, $3, $4, $5));
+                       push(@{$changes->{$2}}, PkgLint::Change->new($line, $1, $2, $3, $4, $5));
                } elsif ($text =~ m"^\t(Added) (\S+) version (\S+) \[(\S+) (\d\d\d\d-\d\d-\d\d)\]$") {
-                       push(@changes, PkgLint::Change->new($line, $1, $2, $3, $4, $5));
+                       push(@{$changes->{$2}}, PkgLint::Change->new($line, $1, $2, $3, $4, $5));
                } elsif ($text =~ m"^\t(Removed) (\S+) (?:successor (\S+) )?\[(\S+) (\d\d\d\d-\d\d-\d\d)\]$") {
-                       push(@changes, PkgLint::Change->new($line, $1, $2, undef, $3, $4));
+                       push(@{$changes->{$2}}, PkgLint::Change->new($line, $1, $2, undef, $3, $4));
                } elsif ($text =~ m"^\t(Downgraded) (\S+) to (\S+) \[(\S+) (\d\d\d\d-\d\d-\d\d)\]$") {
-                       push(@changes, PkgLint::Change->new($line, $1, $2, $3, $4, $5));
+                       push(@{$changes->{$2}}, PkgLint::Change->new($line, $1, $2, $3, $4, $5));
                } elsif ($text =~ m"^\t(Renamed|Moved) (\S+) to (\S+) \[(\S+) (\d\d\d\d-\d\d-\d\d)\]$") {
-                       push(@changes, PkgLint::Change->new($line, $1, $2, $3, $4, $5));
+                       push(@{$changes->{$2}}, PkgLint::Change->new($line, $1, $2, $3, $4, $5));
                } else {
                        $line->log_warning("Unknown doc/CHANGES line: " . $line->text);
                        $line->explain_warning(
@@ -2211,10 +2211,10 @@
 "established by mk/misc/developer.mk?");
                }
        }
-       return \@changes;
-}
-
-my $get_doc_CHANGES_docs = undef; # [ $fname, undef or $lines ]
+       return $changes;
+}
+
+my $get_doc_CHANGES_docs = undef; # [ $fname, undef or { pkgpath -> @changes } ]
 sub get_doc_CHANGES($) {
        my ($pkgpath) = @_;
 
@@ -2243,7 +2243,7 @@
                        $doc->[1] = load_doc_CHANGES("${cwd_pkgsrcdir}/doc/$doc->[0]");
                }
 
-               foreach my $change (@{$doc->[1]}) {
+               foreach my $change (@{$doc->[1]->{$pkgpath}}) {
                        next unless $pkgpath eq $change->pkgpath;
                        push(@result, $change);
                }



Home | Main Index | Thread Index | Old Index