[SCM] Debian package checker branch, master, updated. 2.5.6-6-gadfa403
The following commit has been merged in the master branch:
commit adfa403665b43eba9c688a9d051b18767e00c5a4
Author: Niels Thykier <niels@thykier.net>
Date: Fri Mar 16 13:03:52 2012 +0100
L::Architecture: Lazily evaluate the data file
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/debian/changelog b/debian/changelog
index 3b5871d..1b46446 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,8 @@ lintian (2.5.7) UNRELEASED; urgency=low
* frontend/lintian:
+ [JW] Fix typo in error message.
+ * lib/Lintian/Architecture.pm:
+ + [NT] Lazily evaluate the data file.
* lib/Lintian/Data.pm:
+ [NT] Lazily load data files.
diff --git a/lib/Lintian/Architecture.pm b/lib/Lintian/Architecture.pm
index 8f9057e..b506125 100644
--- a/lib/Lintian/Architecture.pm
+++ b/lib/Lintian/Architecture.pm
@@ -67,23 +67,22 @@ The following methods are exportable:
# Setup code
-my $ARCH_RAW = Lintian::Data->new ('common/architectures', qr/\s*+\Q||\E\s*+/o,
- sub { return [split /\s++/o, $_[1]]});
-
-# Generate the list of valid architecture wildcards.
-my $ARCH_WILDCARDS = {};
+# Valid architecture wildcards.
+my %ARCH_WILDCARDS = ();
-foreach my $archstr ($ARCH_RAW->all) {
- my ($os, $arch);
- next if $archstr eq 'all' or $archstr eq 'any';
- ($os, $arch) = @{ $ARCH_RAW->value($archstr) };
+sub _parse_arch {
+ my ($archstr, $raw) = @_;
+ my ($os, $arch) = split /\s++/o, $raw;
# map $os-any (e.g. "linux-any") and any-$arch (e.g. "any-amd64") to
# the relevant architectures.
- $ARCH_WILDCARDS->{"$os-any"}->{$archstr} = 1;
- $ARCH_WILDCARDS->{"any-$arch"}->{$archstr} = 1;
- $ARCH_WILDCARDS->{'any'}->{$archstr} = 1;
+ $ARCH_WILDCARDS{"$os-any"}->{$archstr} = 1;
+ $ARCH_WILDCARDS{"any-$arch"}->{$archstr} = 1;
+ $ARCH_WILDCARDS{'any'}->{$archstr} = 1;
}
+my $ARCH_RAW = Lintian::Data->new ('common/architectures', qr/\s*+\Q||\E\s*+/o,
+ \&_parse_arch);
+
=item is_arch_wildcard ($wc)
Returns a truth value if $wc is an architecture wildcard.
@@ -94,7 +93,8 @@ Note: 'any' is considered a wildcard and not an architecture.
sub is_arch_wildcard {
my ($wc) = @_;
- return exists $ARCH_WILDCARDS->{$wc} ? 1 : 0;
+ $ARCH_RAW->known ('any') unless %ARCH_WILDCARDS;
+ return exists $ARCH_WILDCARDS{$wc} ? 1 : 0;
}
=item is_arch ($arch)
@@ -142,8 +142,10 @@ its derivaties.
sub expand_arch_wildcard {
my ($wc) = @_;
- return () unless exists $ARCH_WILDCARDS->{$wc};
- return keys %{ $ARCH_WILDCARDS->{$wc} };
+ # Load the wildcards if it has not been done yet.
+ $ARCH_RAW->known ('any') unless %ARCH_WILDCARDS;
+ return () unless exists $ARCH_WILDCARDS{$wc};
+ return keys %{ $ARCH_WILDCARDS{$wc} };
}
=item wildcard_include_arch ($wc, $arch)
@@ -159,7 +161,9 @@ This is generally faster than
sub wildcard_includes_arch {
my ($wc, $arch) = @_;
- return exists $ARCH_WILDCARDS->{$wc}->{$arch} ? 1 : 0;
+ # Load the wildcards if it has not been done yet.
+ $ARCH_RAW->known ('any') unless %ARCH_WILDCARDS;
+ return exists $ARCH_WILDCARDS{$wc}->{$arch} ? 1 : 0;
}
=back
--
Debian package checker
Reply to: