diff options
author | Guillem Jover <guillem@debian.org> | 2012-12-31 21:43:39 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2013-05-04 19:03:13 +0200 |
commit | 6a73e3078b01a71d4a6ea90c85da16523ed56f1d (patch) | |
tree | 4cc7a210e7e851395f7ba4989e3aac4aa9d32710 /scripts/Dpkg/Version.pm | |
parent | 62bc788a45e4a641c28ca9c8c5b9bb08f29faed8 (diff) | |
download | dpkg-6a73e3078b01a71d4a6ea90c85da16523ed56f1d.tar.gz |
Do not use double-quotes on strings that do not need interpolation
Using double-quotes imposes a small performance penalty as the perl
parser needs to check if any interpolation is needed. Use double-quotes
only when the string contains single-quotes. Ideally we'd use
double-quotes too for escaped meta-characters that might otherwise be
confusing to immediately see if they need interpolation or not, but the
policy does not (currently) allow to ignore these.
Fixes ValuesAndExpressions::ProhibitInterpolationOfLiterals.
Warned-by: perlcritic
Diffstat (limited to 'scripts/Dpkg/Version.pm')
-rw-r--r-- | scripts/Dpkg/Version.pm | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm index 420c12fd1..e588e0406 100644 --- a/scripts/Dpkg/Version.pm +++ b/scripts/Dpkg/Version.pm @@ -21,7 +21,7 @@ package Dpkg::Version; use strict; use warnings; -our $VERSION = "1.00"; +our $VERSION = '1.00'; use Dpkg::ErrorHandling; use Dpkg::Gettext; @@ -155,7 +155,7 @@ its string representation is a version number. sub comparison { my ($a, $b, $inverted) = @_; - if (not ref($b) or not $b->isa("Dpkg::Version")) { + if (not ref($b) or not $b->isa('Dpkg::Version')) { $b = Dpkg::Version->new($b); } ($a, $b) = ($b, $a) if $inverted; @@ -174,10 +174,10 @@ Returns the string representation of the version number. sub as_string { my ($self) = @_; - my $str = ""; - $str .= $self->{epoch} . ":" unless $self->{no_epoch}; + my $str = ''; + $str .= $self->{epoch} . ':' unless $self->{no_epoch}; $str .= $self->{version}; - $str .= "-" . $self->{revision} unless $self->{no_revision}; + $str .= '-' . $self->{revision} unless $self->{no_revision}; return $str; } @@ -201,9 +201,9 @@ If $a or $b are not valid version numbers, it dies with an error. sub version_compare($$) { my ($a, $b) = @_; my $va = Dpkg::Version->new($a, check => 1); - defined($va) || error(_g("%s is not a valid version"), "$a"); + defined($va) || error(_g('%s is not a valid version'), "$a"); my $vb = Dpkg::Version->new($b, check => 1); - defined($vb) || error(_g("%s is not a valid version"), "$b"); + defined($vb) || error(_g('%s is not a valid version'), "$b"); return $va <=> $vb; } @@ -250,7 +250,7 @@ they are obsolete aliases of ">=" and "<=". sub version_normalize_relation($) { my $op = shift; - warning("relation %s is deprecated: use %s or %s", + warning('relation %s is deprecated: use %s or %s', $op, "$op$op", "$op=") if ($op eq '>' or $op eq '<'); if ($op eq '>>' or $op eq 'gt') { @@ -369,12 +369,12 @@ sub version_check($) { $version = Dpkg::Version->new($str) unless ref($version); } if (not defined($str) or not length($str)) { - my $msg = _g("version number cannot be empty"); + my $msg = _g('version number cannot be empty'); return (0, $msg) if wantarray; return 0; } if ($version->version() =~ m/^[^\d]/) { - my $msg = _g("version number does not start with digit"); + my $msg = _g('version number does not start with digit'); return (0, $msg) if wantarray; return 0; } @@ -384,12 +384,12 @@ sub version_check($) { return 0; } if ($version->epoch() !~ /^\d*$/) { - my $msg = sprintf(_g("epoch part of the version number " . + my $msg = sprintf(_g('epoch part of the version number ' . "is not a number: '%s'"), $version->epoch()); return (0, $msg) if wantarray; return 0; } - return (1, "") if wantarray; + return (1, '') if wantarray; return 1; } |