diff options
author | rillig <rillig@pkgsrc.org> | 2015-10-11 14:31:36 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2015-10-11 14:31:36 +0000 |
commit | 51249e8e98cd0c568582596158dccc0b16ba8c96 (patch) | |
tree | 0ab188b43b2776ec66d815cd9a92b344a3ca4f3e | |
parent | b99b5e8bfe0ce7fa54a67e410ecafae7ae3ccfa4 (diff) | |
download | pkgsrc-51249e8e98cd0c568582596158dccc0b16ba8c96.tar.gz |
Performance: removed some needless string interpolations
-rw-r--r-- | pkgtools/pkglint/files/PkgLint/FileUtil.pm | 2 | ||||
-rw-r--r-- | pkgtools/pkglint/files/PkgLint/Line.pm | 10 | ||||
-rw-r--r-- | pkgtools/pkglint/files/pkglint.pl | 17 |
3 files changed, 18 insertions, 11 deletions
diff --git a/pkgtools/pkglint/files/PkgLint/FileUtil.pm b/pkgtools/pkglint/files/PkgLint/FileUtil.pm index ad7d1945396..399bfe2356c 100644 --- a/pkgtools/pkglint/files/PkgLint/FileUtil.pm +++ b/pkgtools/pkglint/files/PkgLint/FileUtil.pm @@ -34,7 +34,7 @@ sub load_physical_lines($) { my ($physlines, $line, $lineno); $physlines = []; - open(F, "< $fname") or return undef; + open(F, "<", $fname) or return undef; $lineno = 0; while (defined($line = <F>)) { $lineno++; diff --git a/pkgtools/pkglint/files/PkgLint/Line.pm b/pkgtools/pkglint/files/PkgLint/Line.pm index 8a4f12d9a5a..6f22821e954 100644 --- a/pkgtools/pkglint/files/PkgLint/Line.pm +++ b/pkgtools/pkglint/files/PkgLint/Line.pm @@ -50,12 +50,14 @@ sub has($$) { } sub get($$) { my ($self, $name) = @_; - assert(exists($self->[EXTRA]->{$name}), "Field ${name} does not exist."); + assert(false, "Field ${name} does not exist.") + unless exists($self->[EXTRA]->{$name}); return $self->[EXTRA]->{$name}; } sub set($$$) { my ($self, $name, $value) = @_; - assert(!exists($self->[EXTRA]->{$name}), "Field ${name} already exists."); + assert(false, "Field ${name} already exists.") + if exists($self->[EXTRA]->{$name}); # Make sure that the line does not become a cyclic data structure. my $type = ref($value); @@ -64,8 +66,8 @@ sub set($$$) { } elsif ($type eq "ARRAY") { foreach my $element (@{$value}) { my $element_type = ref($element); - assert($element_type eq "" || $element_type eq "PkgLint::SimpleMatch", - "Invalid array data type: name=${name}, type=${element_type}."); + assert(false, "Invalid array data type: name=${name}, type=${element_type}.") + unless $element_type eq "" || $element_type eq "PkgLint::SimpleMatch"; } } else { assert(false, "Invalid data: name=${name}, value=${value}."); diff --git a/pkgtools/pkglint/files/pkglint.pl b/pkgtools/pkglint/files/pkglint.pl index a5bde7f687c..1d7f571e491 100644 --- a/pkgtools/pkglint/files/pkglint.pl +++ b/pkgtools/pkglint/files/pkglint.pl @@ -1,5 +1,5 @@ #! @PERL@ -# $NetBSD: pkglint.pl,v 1.882 2015/10/11 12:31:43 rillig Exp $ +# $NetBSD: pkglint.pl,v 1.883 2015/10/11 14:31:36 rillig Exp $ # # pkglint - static analyzer and checker for pkgsrc packages @@ -1769,7 +1769,8 @@ sub check_pkglint_version() { sub lines_log_warning($$$) { my ($lines, $lineno, $msg) = @_; - assert(0 <= $lineno, "The line number is negative (${lineno})."); + assert(false, "The line number is negative (${lineno}).") + unless 0 <= $lineno; assert(@{$lines} != 0, "The lines may not be empty."); if ($lineno <= $#{$lines}) { @@ -7167,10 +7168,14 @@ sub checkdir_CVS($) { foreach my $line (@$cvs_entries) { my ($type, $fname, $mtime, $date, $keyword_mode, $tag, $undef) = my_split("/", $line->text); next if ($type eq "D" && !defined($fname)); - assert($type eq "" || $type eq "D", "Unknown line format: " . $line->text); - assert(defined($tag), "Unknown line format: " . $line->text); - assert(defined($keyword_mode), "Unknown line format: " . $line->text); - assert(!defined($undef), "Unknown line format: " . $line->text); + assert(false, "Unknown line format: " . $line->text) + unless $type eq "" || $type eq "D"; + assert(false, "Unknown line format: " . $line->text) + unless defined($tag); + assert(false, "Unknown line format: " . $line->text) + unless defined($keyword_mode); + assert(false, "Unknown line format: " . $line->text) + if defined($undef); } } |