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/Shlibs/Symbol.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/Shlibs/Symbol.pm')
-rw-r--r-- | scripts/Dpkg/Shlibs/Symbol.pm | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/scripts/Dpkg/Shlibs/Symbol.pm b/scripts/Dpkg/Shlibs/Symbol.pm index 8e5bfcf28..ae53e43ce 100644 --- a/scripts/Dpkg/Shlibs/Symbol.pm +++ b/scripts/Dpkg/Shlibs/Symbol.pm @@ -19,7 +19,7 @@ package Dpkg::Shlibs::Symbol; use strict; use warnings; -our $VERSION = "0.01"; +our $VERSION = '0.01'; use Dpkg::Gettext; use Dpkg::Deps; @@ -66,7 +66,7 @@ sub parse_tagspec { # (tag1=t1 value|tag2|...|tagN=tNp) # Symbols ()|= cannot appear in the tag names and values my $tagspec = $1; - my $rest = ($2) ? $2 : ""; + my $rest = ($2) ? $2 : ''; my @tags = split(/\|/, $tagspec); # Parse each tag @@ -108,7 +108,7 @@ sub parse_symbolspec { $rest = $2; } } - error(_g("symbol name unspecified: %s"), $symbolspec) if (!$symbol); + error(_g('symbol name unspecified: %s'), $symbolspec) if (!$symbol); } else { # No tag specification. Symbol name is up to the first space # foobarsymbol@Base 1.0 1 @@ -155,8 +155,8 @@ sub initialize { # Support old style wildcard syntax. That's basically a symver # with an optional tag. if ($self->get_symbolname() =~ /^\*@(.*)$/) { - $self->add_tag("symver") unless $self->has_tag("symver"); - $self->add_tag("optional") unless $self->has_tag("optional"); + $self->add_tag('symver') unless $self->has_tag('symver'); + $self->add_tag('optional') unless $self->has_tag('optional'); $self->{symbol} = $1; } @@ -164,7 +164,7 @@ sub initialize { # Each symbol is matched against its version rather than full # name@version string. $type = (defined $type) ? 'generic' : 'alias-symver'; - if ($self->get_symbolname() eq "Base") { + if ($self->get_symbolname() eq 'Base') { error(_g("you can't use symver tag to catch unversioned symbols: %s"), $self->get_symbolspec(1)); } @@ -282,12 +282,12 @@ sub equals { sub is_optional { my $self = shift; - return $self->has_tag("optional"); + return $self->has_tag('optional'); } sub is_arch_specific { my $self = shift; - return $self->has_tag("arch"); + return $self->has_tag('arch'); } sub arch_is_concerned { @@ -297,7 +297,7 @@ sub arch_is_concerned { if (defined $arch && defined $arches) { my $dep = Dpkg::Deps::Simple->new(); my @arches = split(/[\s,]+/, $arches); - $dep->{package} = "dummy"; + $dep->{package} = 'dummy'; $dep->{arches} = \@arches; return $dep->arch_is_concerned($arch); } @@ -328,13 +328,13 @@ sub is_pattern { # Get pattern type if this symbol is a pattern. sub get_pattern_type { - return $_[0]->{pattern}{type} || ""; + return $_[0]->{pattern}{type} || ''; } # Get (sub)type of the alias pattern. Returns empty string if current # pattern is not alias. sub get_alias_type { - return ($_[0]->get_pattern_type() =~ /^alias-(.+)/ && $1) || ""; + return ($_[0]->get_pattern_type() =~ /^alias-(.+)/ && $1) || ''; } # Get a list of symbols matching this pattern if this symbol is a pattern @@ -377,7 +377,7 @@ sub convert_to_alias { # In case of symver, alias is symbol version. Extract it from the # rawname. return "$1" if ($rawname =~ /\@([^@]+)$/); - } elsif ($rawname =~ /^_Z/ && $type eq "c++") { + } elsif ($rawname =~ /^_Z/ && $type eq 'c++') { return cppfilt_demangle_cpp($rawname); } } @@ -391,26 +391,26 @@ sub get_tagspec { for my $tagname (@{$self->{tagorder}}) { my $tagval = $self->{tags}{$tagname}; if (defined $tagval) { - push @tags, $tagname . "=" . $tagval; + push @tags, $tagname . '=' . $tagval; } else { push @tags, $tagname; } } - return "(". join("|", @tags) . ")"; + return '(' . join('|', @tags) . ')'; } - return ""; + return ''; } sub get_symbolspec { my $self = shift; my $template_mode = shift; - my $spec = ""; + my $spec = ''; $spec .= "#MISSING: $self->{deprecated}#" if $self->{deprecated}; - $spec .= " "; + $spec .= ' '; if ($template_mode) { if ($self->has_tags()) { $spec .= sprintf('%s%3$s%s%3$s', $self->get_tagspec(), - $self->get_symboltempl(), $self->{symbol_quoted} || ""); + $self->get_symboltempl(), $self->{symbol_quoted} || ''); } else { $spec .= $self->get_symboltempl(); } @@ -487,7 +487,7 @@ sub matches_rawname { for my $tag (@{$self->{tagorder}}) { if (grep { $tag eq $_ } ALIAS_TYPES) { $ok = not not ($target = $self->convert_to_alias($target, $tag)); - } elsif ($tag eq "regex") { + } elsif ($tag eq 'regex') { # Symbol name is a regex. Match it against the target $do_eq_match = 0; $ok = ($target =~ $self->{pattern}{regex}); |