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

[lintian] 02/15: L::L::Manifest: Merge _do_get into get



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

nthykier pushed a commit to branch master
in repository lintian.

commit 816ff2d44e4c875510cde28cfab3e565126b26df
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Feb 7 20:10:40 2014 +0100

    L::L::Manifest: Merge _do_get into get
    
    The call overhead is vastly greater than the "if-statement" that was
    by-passed in _do_get.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 lib/Lintian/Lab/Manifest.pm | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/lib/Lintian/Lab/Manifest.pm b/lib/Lintian/Lab/Manifest.pm
index 762222b..c5d8843 100644
--- a/lib/Lintian/Lab/Manifest.pm
+++ b/lib/Lintian/Lab/Manifest.pm
@@ -262,7 +262,7 @@ sub visit_all {
     my (undef, undef, $qf) = $self->_type_to_fields;
 
     if (@keys) {
-        $root = $self->_do_get(@keys);
+        $root = $self->get(@keys);
         return unless $root;
         if (scalar @$qf == scalar @keys) {
             # If we are given an exact match, just visit that and
@@ -302,8 +302,18 @@ except for source packages
 
 sub get {
     my ($self, @keys) = @_;
-    @keys = $self->_make_keys($keys[0]) if scalar @keys == 1;
-    return $self->_do_get(@keys);
+    my $cur = $self->{'state'};
+    my (undef, undef, $qf) = $self->_type_to_fields;
+    my $max = scalar @$qf;
+    @keys = $self->_make_keys($keys[0])
+      if scalar(@keys) == 1 && ref($keys[0]);
+    $max = scalar @keys if scalar @keys < $max;
+    for (my $i = 0 ; $i < $max ; $i++) {
+        my $key = $keys[$i];
+        $cur = $cur->{$key};
+        return unless defined $cur;
+    }
+    return $cur;
 }
 
 sub _make_keys {
@@ -409,7 +419,7 @@ sub _do_delete {
     return 0 unless defined $lk;
 
     if (@keys) {
-        $hash = $self->_do_get(@keys);
+        $hash = $self->get(@keys);
     } else {
         $hash = $self->{'state'};
     }
@@ -559,20 +569,6 @@ sub _make_alias_fields {
     return;
 }
 
-sub _do_get {
-    my ($self, @keys) = @_;
-    my $cur = $self->{'state'};
-    my (undef, undef, $qf) = $self->_type_to_fields;
-    my $max = scalar @$qf;
-    $max = scalar @keys if scalar @keys < $max;
-    for (my $i = 0 ; $i < $max ; $i++) {
-        my $key = $keys[$i];
-        $cur = $cur->{$key};
-        return unless defined $cur;
-    }
-    return $cur;
-}
-
 sub _do_set {
     my ($self, $qf, $entry, $root) = @_;
     my $qfl = scalar @$qf - 1; # exclude the last element (see below)

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


Reply to: