From 9e5e03e9a6ddf74bb22ffc5ea8794a14a592d6b6 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 28 Sep 2017 09:28:24 +0200 Subject: Dpkg::Control::HashCore: Optimize field/value parsing in parse() We switch from a capturing regex to split() plus a checking regex. --- scripts/Dpkg/Control/HashCore.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg/Control') diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index a138698a4..e83522729 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -211,9 +211,10 @@ sub parse { my $lead = substr $_, 0, 1; next if $lead eq '#'; $paraborder = 0; - if (m/^(\S+?)\s*:\s*(.*)$/) { + + my ($name, $value) = split /\s*:\s*/, $_, 2; + if (defined $name and $name =~ m/^\S+?$/) { $parabody = 1; - my ($name, $value) = ($1, $2); if ($lead eq '-') { $self->parse_error($desc, g_('field cannot start with a hyphen')); } -- cgit v1.2.3