[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 02/04: L::Path::FSInfo: Cache the FS root path



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 19f457bcd882206cd74b4173766111179399202d
Author: Niels Thykier <niels@thykier.net>
Date:   Tue Oct 7 21:23:41 2014 +0200

    L::Path::FSInfo: Cache the FS root path
    
    Since all input is known to be normalised, L::P::FSInfo can also
    dispense with a few "formalities" (read: checking) that the underlying
    method in L::Collect would need to do.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 lib/Lintian/Path/FSInfo.pm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/Lintian/Path/FSInfo.pm b/lib/Lintian/Path/FSInfo.pm
index d09f359..cfd9012 100644
--- a/lib/Lintian/Path/FSInfo.pm
+++ b/lib/Lintian/Path/FSInfo.pm
@@ -73,6 +73,12 @@ that it represents.
 
 sub _underlying_fs_path {
     my ($self, $path) = @_;
+    my $fs_root;
+    my $fname = $path->name;
+    if ($fs_root = $self->{'_root_fs_path'}) {
+        return join('/', $fs_root, $fname) if $fname ne q{};
+        return $fs_root;
+    }
     my $collect = $self->{'_collect'};
     my $collect_sub = $self->{'_collect_path_sub'};
     if (not defined($collect_sub)) {
@@ -82,11 +88,11 @@ sub _underlying_fs_path {
         # Disable the deprecation warning from (e.g.) control.  It is
         # not meant for this call.
         no warnings qw(deprecated);
-        return $collect->$collect_sub($path);
+        $fs_root = $collect->$collect_sub();
     };
-    # Perl Critic is too blind to realise that this is unreachable,
-    # so we need an additional return here.
-    return;
+    $self->{'_root_fs_path'} = $fs_root;
+    return join('/', $fs_root, $fname) if $fname ne q{};
+    return $fs_root;
 }
 
 =item has_anchored_root_dir

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: