The following commit has been merged in the master branch:
commit a4c8c4b56b11038e3d1cb8d312fe149e9c3d1384
Author: Guillem Jover <[email protected]>
Date:   Tue Jan 1 16:57:32 2013 +0100

    Dpkg::Changelog: Refactor out _is_full_range()
    
    This also avoids a regex match and a grep on boolean context, which is
    suboptimal as the whole list needs to be traversed.
    
    Addresses BuiltinFunctions::ProhibitBooleanGrep.
    
    Warned-by: perlcritic

diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm
index a0911f4..d421ea8 100644
--- a/scripts/Dpkg/Changelog.pm
+++ b/scripts/Dpkg/Changelog.pm
@@ -338,16 +338,25 @@ sub get_range {
     }
 }
 
+sub _is_full_range {
+    my ($self, $range) = @_;
+
+    return 1 if $range->{all};
+
+    # If no range delimiter is specified, we want everything.
+    foreach (qw(since until from to count offset)) {
+        return 0 if exists $range->{$_};
+    }
+
+    return 1;
+}
+
 sub _data_range {
     my ($self, $range) = @_;
 
     my $data = $self->{data} or return;
 
-    return [ @$data ] if $range->{all};
-
-    unless (grep { m/^(since|until|from|to|count|offset)$/ } keys %$range) {
-       return [ @$data ];
-    }
+    return [ @$data ] if $self->_is_full_range($range);
 
     $self->__sanity_check_range($range);
 
@@ -410,8 +419,7 @@ sub abort_early {
     my $count = $r->{count} || 0;
     my $offset = $r->{offset} || 0;
 
-    return if $r->{all};
-    return unless grep { m/^(since|until|from|to|count|offset)$/ } keys %$r;
+    return if $self->_is_full_range($r);
     return if $offset < 0 or $count < 0;
     if (defined($r->{count})) {
        if ($offset > 0) {

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to