[dpkg] 169/192: Dpkg::Control::HashCore: Optimize field/value parsing in parse()
Ximin Luo
infinity0 at debian.org
Tue Oct 17 11:04:14 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch pu/reproducible_builds
in repository dpkg.
commit 9e5e03e9a6ddf74bb22ffc5ea8794a14a592d6b6
Author: Guillem Jover <guillem at debian.org>
Date: Thu Sep 28 09:28:24 2017 +0200
Dpkg::Control::HashCore: Optimize field/value parsing in parse()
We switch from a capturing regex to split() plus a checking regex.
---
debian/changelog | 2 ++
scripts/Dpkg/Control/HashCore.pm | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index b49af6d..be4d7d5 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 a138698..e835227 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'));
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list