[lintian] 03/03: L::Path: Replace the dirname field with parent->name
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 8dacc8e978579fa57bce7b39517eb22f2b35e15c
Author: Niels Thykier <niels@thykier.net>
Date: Fri Jul 17 20:36:00 2015 +0200
L::Path: Replace the dirname field with parent->name
This yield another 2% - 2.5% saving in memory used by the L::Collect
caches used when processing lintian.
Signed-off-by: Niels Thykier <niels@thykier.net>
---
lib/Lintian/Collect/Package.pm | 11 +----------
lib/Lintian/Path.pm | 12 ++++++++++--
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/lib/Lintian/Collect/Package.pm b/lib/Lintian/Collect/Package.pm
index 2968df2..f3ef628 100644
--- a/lib/Lintian/Collect/Package.pm
+++ b/lib/Lintian/Collect/Package.pm
@@ -489,12 +489,8 @@ sub _fetch_index_data {
# Record children
$children{$name} ||= [] if $raw_type eq 'd';
- my ($parent, $base) = ($name =~ m,^(.+/)?([^/]+/?)$,);
+ my ($parent) = ($name =~ m,^(.+/)?(?:[^/]+/?)$,);
$parent = '' unless defined $parent;
- $base = '' unless defined $base;
- # Insert the dirname field later for all (non-root) entries as
- # it allows us to better reuse memory.
- $file{dirname} = '' if $base eq '';
$children{$parent} = [] unless exists $children{$parent};
@@ -516,8 +512,6 @@ sub _fetch_index_data {
my ($parent) = ($name =~ m,^(.+/)?(?:[^/]+/?)$,);
$parent //= '';
$cpy{'name'} = $name;
- # Re: above, only insert dirname now for the root entry.
- $cpy{'dirname'} = q{} if $name eq q{};
if ($num_idx) {
$cpy{'uid'} = 0;
$cpy{'gid'} = 0;
@@ -588,9 +582,6 @@ sub _fetch_index_data {
for my $cname (sort(@{ $children{$file} })) {
my $child = $idxh{$cname};
my $basename = $child->basename;
- # Insert dirname here to share the same storage with
- # the hash key
- $child->{'dirname'} = $file;
if (substr($basename, -1, 1) eq '/') {
$basename = substr($basename, 0, -1);
}
diff --git a/lib/Lintian/Path.pm b/lib/Lintian/Path.pm
index 240555d..0b1df56 100644
--- a/lib/Lintian/Path.pm
+++ b/lib/Lintian/Path.pm
@@ -188,6 +188,15 @@ File::Basename::dirname. The dirname will end with a trailing slash
NB: Returns the empty string for the "root" dir.
+=cut
+
+sub dirname {
+ my ($self) = @_;
+ my $dir = $self->parent_dir;
+ return $dir->name if $dir;
+ return q{};
+}
+
=item basename
Returns the "filename" part of the name, similar basename(1) or
@@ -222,8 +231,7 @@ happen if a package does not include all intermediate directories.
Lintian::Path->mk_ro_accessors(
qw(name owner group link uid gid
- size date time parent_dir dirname
- faux
+ size date time parent_dir faux
));
=item operm
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: