summaryrefslogtreecommitdiff
path: root/pkgtools
diff options
context:
space:
mode:
authorrillig <rillig@pkgsrc.org>2009-04-26 12:51:35 +0000
committerrillig <rillig@pkgsrc.org>2009-04-26 12:51:35 +0000
commitf0de3ee1bbb3a42f0f1ee7119971392165410246 (patch)
treec7280d694bd69afe8357a3ee01d218f295728f5d /pkgtools
parent92e36a3f3c2c9a79260d5ea39a59371e25685fe1 (diff)
downloadpkgsrc-f0de3ee1bbb3a42f0f1ee7119971392165410246.tar.gz
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 (limited to 'pkgtools')
-rw-r--r--pkgtools/pkglint/files/pkglint.pl20
1 files changed, 10 insertions, 10 deletions
diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl
index f9959483a94..4b89244387a 100644
--- a/pkgtools/pkglint/files/pkglint.pl
+++ b/pkgtools/pkglint/files/pkglint.pl
@@ -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 @@ sub load_doc_CHANGES($) {
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 @@ sub load_doc_CHANGES($) {
"established by mk/misc/developer.mk?");
}
}
- return \@changes;
+ return $changes;
}
-my $get_doc_CHANGES_docs = undef; # [ $fname, undef or $lines ]
+my $get_doc_CHANGES_docs = undef; # [ $fname, undef or { pkgpath -> @changes } ]
sub get_doc_CHANGES($) {
my ($pkgpath) = @_;
@@ -2243,7 +2243,7 @@ sub get_doc_CHANGES($) {
$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);
}