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

[lintian] 01/01: L::L::Entry: Optimise out a few stat() calls



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

nthykier pushed a commit to branch master
in repository lintian.

commit e948fca50bc96d0c9b50f0d4895f26db02ef05cb
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Feb 13 19:25:43 2015 +0100

    L::L::Entry: Optimise out a few stat() calls
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 lib/Lintian/Lab/Entry.pm | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/lib/Lintian/Lab/Entry.pm b/lib/Lintian/Lab/Entry.pm
index 14d195d..db28d30 100644
--- a/lib/Lintian/Lab/Entry.pm
+++ b/lib/Lintian/Lab/Entry.pm
@@ -64,9 +64,10 @@ use Carp qw(croak);
 use Cwd();
 use File::Spec;
 use Scalar::Util qw(refaddr);
+use POSIX qw();
 
 use Lintian::Lab;
-use Lintian::Util qw(delete_dir read_dpkg_control get_dsc_info strip);
+use Lintian::Util qw(delete_dir parse_dpkg_control get_dsc_info strip);
 
 # This is the entry format version - this changes whenever the layout of
 # entries changes.  This differs from LAB_FORMAT in that LAB_FORMAT
@@ -373,7 +374,6 @@ sub update_status_file {
     my @sc;
 
     unless ($self->exists) {
-        require POSIX;
         $! = POSIX::ENOENT;
         return 0;
     }
@@ -405,10 +405,21 @@ sub update_status_file {
 sub _init {
     my ($self, $newentry) = @_;
     my $base_dir = $self->base_dir;
-    my @data;
-    my $head;
-    my $coll;
-    my $exists = $self->exists;
+    my (@data, $head, $coll, $fd, $exists);
+
+    eval {
+        use autodie qw(open);
+        open($fd, '<', "$base_dir/.lintian-status");
+        # If the status file exists, then so does the
+        # entry.
+        $exists = 1;
+    };
+    if (my $err = $@) {
+        die($err) if $err->errno != POSIX::ENOENT;
+        $exists = $self->exists;
+    }
+    @data = parse_dpkg_control($fd);
+    close($fd);
 
     if ($newentry) {
         my $pkg_path = $self->pkg_path;
@@ -438,8 +449,6 @@ sub _init {
     }
 
     return unless $exists;
-    return unless -e "$base_dir/.lintian-status";
-    @data = read_dpkg_control("$base_dir/.lintian-status");
     $head = $data[0];
 
     # Check that we know the format.

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


Reply to: