From a76b755572bfd7b106ef283193d32fba8cbc5dd1 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 28 Sep 2017 09:28:24 +0200 Subject: Dpkg::Control::HashCore: Optimize first character matching in parse() We store the first character in a variable. --- scripts/Dpkg/Control/HashCore.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg/Control') diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index f33c15605..a138698a4 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -207,12 +207,14 @@ sub parse { s/\s+$//; next if length == 0 and $paraborder; - next if substr($_, 0, 1) eq '#'; + + my $lead = substr $_, 0, 1; + next if $lead eq '#'; $paraborder = 0; if (m/^(\S+?)\s*:\s*(.*)$/) { $parabody = 1; my ($name, $value) = ($1, $2); - if (substr($name, 0, 1) eq '-') { + if ($lead eq '-') { $self->parse_error($desc, g_('field cannot start with a hyphen')); } if (exists $self->{$name}) { -- cgit v1.2.3