summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2017-09-28 09:28:24 +0200
committerGuillem Jover <guillem@debian.org>2017-10-16 11:04:29 +0200
commit9e5e03e9a6ddf74bb22ffc5ea8794a14a592d6b6 (patch)
tree681b5589ce6024c42d76f0dca2b4f0dea330c816
parenta76b755572bfd7b106ef283193d32fba8cbc5dd1 (diff)
downloaddpkg-9e5e03e9a6ddf74bb22ffc5ea8794a14a592d6b6.tar.gz
Dpkg::Control::HashCore: Optimize field/value parsing in parse()
We switch from a capturing regex to split() plus a checking regex.
-rw-r--r--debian/changelog2
-rw-r--r--scripts/Dpkg/Control/HashCore.pm5
2 files changed, 5 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index b49af6de7..be4d7d5cd 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -100,6 +100,8 @@ dpkg (1.19.0) UNRELEASED; urgency=medium
method, by requiring that at least one whitespace is present.
- Optimize first character matching in Dpkg::Control::HashCore parse
method, by storing the first character in a variable.
+ - Optimize field/value parsing in Dpkg::Control::HashCore parse method,
+ by switching from a capturing regex to split() plus a checking regex.
* Documentation:
- Document currently accepted syntax for changelogs in deb-changelog(5).
Closes: #858579
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'));
}