[lintian] 04/05: L::Path: Only store _fs_info on dir entries
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 63656357756ccfabab7091c37f8acd76700cb2f1
Author: Niels Thykier <niels@thykier.net>
Date: Thu Jul 16 22:18:06 2015 +0200
L::Path: Only store _fs_info on dir entries
Reduces cached memory by ~2% on lintian.
Signed-off-by: Niels Thykier <niels@thykier.net>
---
lib/Lintian/Collect/Package.pm | 3 +--
lib/Lintian/Path.pm | 15 ++++++++++++---
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/lib/Lintian/Collect/Package.pm b/lib/Lintian/Collect/Package.pm
index 69605da..b0e7977 100644
--- a/lib/Lintian/Collect/Package.pm
+++ b/lib/Lintian/Collect/Package.pm
@@ -474,7 +474,6 @@ sub _fetch_index_data {
# reason for storing it now is that we may need it during the
# "hard-link fixup"-phase.
$file{'name'} = $name = dequote_name($name);
- $file{'_fs_info'} = $fs_info;
$idxh{$name} = \%file;
@@ -508,7 +507,6 @@ sub _fetch_index_data {
my ($parent, $base) = ($name =~ m,^(.+/)?([^/]+/?)$,);
$parent //= '';
$base //= '';
- $cpy{'_fs_info'} = $fs_info;
$cpy{'name'} = $name;
$cpy{'basename'} = $base;
# Re: above, only insert dirname now for the root entry.
@@ -590,6 +588,7 @@ sub _fetch_index_data {
@sorted_children = reverse(@sorted_children);
$entry->{'_sorted_children'} = \@sorted_children;
$entry->{'children'} = \%child_table;
+ $entry->{'_fs_info'} = $fs_info;
}
# Insert name here to share the same storage with the hash key
$entry->{'name'} = $file;
diff --git a/lib/Lintian/Path.pm b/lib/Lintian/Path.pm
index a6d4261..32f0211 100644
--- a/lib/Lintian/Path.pm
+++ b/lib/Lintian/Path.pm
@@ -386,7 +386,7 @@ sub file_info {
if (my $file_info = $self->{'_file_info'}) {
return $file_info;
}
- $file_info = $self->{'_fs_info'}->_file_info($self);
+ $file_info = $self->_fs_info->_file_info($self);
$self->{'_file_info'} = $file_info;
return $file_info;
}
@@ -454,7 +454,16 @@ sub is_open_ok {
sub _collect_path {
my ($self) = @_;
- return $self->{'_fs_info'}->_underlying_fs_path($self);
+ return $self->_fs_info->_underlying_fs_path($self);
+}
+
+sub _fs_info {
+ my ($self) = @_;
+ # Technically, this will look up the parent dir even if $self is a dir
+ # - though calling is_dir first is probably more expensive than just
+ # blindly calling parent_dir
+ my $dir = $self->parent_dir // $self;
+ return $dir->{'_fs_info'};
}
sub _check_access {
@@ -631,7 +640,7 @@ sub resolve_path {
my ($self, $path_str) = @_;
my $current = $self;
my (@queue, %traversed_links, $had_trailing_slash);
- my $fs_info = $self->{'_fs_info'};
+ my $fs_info = $self->_fs_info;
if (defined($path_str) and ref($path_str) ne q{}) {
croak('resolve_path only accepts string arguments');
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: