[SCM] Debian package checker branch, master, updated. 2.5.14-40-ged90304
The following commit has been merged in the master branch:
commit ed903040706f10414fd708545f163834f5a3d6ef
Author: Niels Thykier <niels@thykier.net>
Date: Fri Jul 5 13:09:37 2013 +0200
L::C::Package: Intern values from file(1)
A trivial interning of the values from file(1) can reduce the memory
overhead of file_info for source:linux by 2.5-3.0 MB (down from ~8MB).
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/debian/changelog b/debian/changelog
index 7c78d42..4c96392 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -58,8 +58,8 @@ lintian (2.5.15) UNRELEASED; urgency=low
of the memory usage with -dddd.
* lib/Lintian/Collect/Package.pm:
- + [NT] Share some string values in index functions. This
- reduces memory usage a bit.
+ + [NT] Share some string values in the file_info and in
+ the (X_)index methods. This reduces memory usage a bit.
* lib/Lintian/Collect/Source.pm:
+ [NT] "binaries" and "binary_field" now only exposes data
about entries in d/control with a valid package name.
diff --git a/lib/Lintian/Collect/Package.pm b/lib/Lintian/Collect/Package.pm
index 17b2e4b..c4c075f 100644
--- a/lib/Lintian/Collect/Package.pm
+++ b/lib/Lintian/Collect/Package.pm
@@ -157,10 +157,11 @@ Needs-Info requirements for using I<file_info>: file-info
sub file_info {
my ($self, $file) = @_;
if (exists $self->{file_info}) {
- return $self->{file_info}->{$file}
+ return ${$self->{file_info}{$file}}
if exists $self->{file_info}->{$file};
return;
}
+ my %interned;
my %file_info;
my $path = $self->lab_data_path ('file-info.gz');
local $_;
@@ -171,15 +172,24 @@ sub file_info {
m/^(.+?)\x00\s+(.*)$/o
or croak "an error in the file pkg is preventing lintian from checking this package: $_";
my ($file, $info) = ($1,$2);
+ my $ref = $interned{$info};
$file =~ s,^\./,,o;
- $file_info{$file} = $info;
+ if (!defined($ref)) {
+ # Store a ref to the info to avoid creating a new copy
+ # each time. We just have to deref the reference on
+ # return. TODO: Test if this will be obsolete by
+ # COW variables in Perl 5.20.
+ $interned{$info} = $ref = \$info;
+ }
+
+ $file_info{$file} = $ref;
}
close($idx);
$self->{file_info} = \%file_info;
- return $self->{file_info}->{$file}
+ return ${$self->{file_info}{$file}}
if exists $self->{file_info}->{$file};
return;
}
--
Debian package checker
Reply to: