diff options
author | Guillem Jover <guillem@debian.org> | 2017-09-28 09:28:24 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2017-10-16 11:04:29 +0200 |
commit | 9e5e03e9a6ddf74bb22ffc5ea8794a14a592d6b6 (patch) | |
tree | 681b5589ce6024c42d76f0dca2b4f0dea330c816 /scripts/Dpkg/Control | |
parent | a76b755572bfd7b106ef283193d32fba8cbc5dd1 (diff) | |
download | dpkg-9e5e03e9a6ddf74bb22ffc5ea8794a14a592d6b6.tar.gz |
Dpkg::Control::HashCore: Optimize field/value parsing in parse()
We switch from a capturing regex to split() plus a checking regex.
Diffstat (limited to 'scripts/Dpkg/Control')
-rw-r--r-- | scripts/Dpkg/Control/HashCore.pm | 5 |
1 files changed, 3 insertions, 2 deletions
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')); } |