diff options
author | Julian Andres Klode <jak@debian.org> | 2016-09-28 00:49:45 +0200 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2016-11-22 22:58:33 +0100 |
commit | 49521f87851089bdb4097b715d09a8bd348aa60a (patch) | |
tree | 7cedcd05be67505f4949eb18dbe155178b76e4bb /apt-pkg/deb/deblistparser.cc | |
parent | c0723bf1a60daf45096998d4ae9feee3c44343f8 (diff) |
Do not use MD5SumValue for Description_md5()
Our profile says we spend about 5% of the time transforming the
hex digits into the binary format used by HashsumValue, all for
comparing them against the other strings. That makes no sense
at all.
According to callgrind, this reduces the overall instruction
count from 5,3 billion to 5 billion in my example, which
roughly matches the 5%.
Diffstat (limited to 'apt-pkg/deb/deblistparser.cc')
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index ea4d8e063..0fc08d8fb 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -276,31 +276,27 @@ std::vector<std::string> debListParser::AvailableDescriptionLanguages() description. If no Description-md5 is found in the section it will be calculated. */ -MD5SumValue debListParser::Description_md5() +APT::StringView debListParser::Description_md5() { StringView const value = Section.Find(pkgTagSection::Key::Description_md5); - if (value.empty() == true) + if (unlikely(value.empty() == true)) { StringView const desc = Section.Find(pkgTagSection::Key::Description); if (desc == "\n") - return MD5SumValue(); + return StringView(); MD5Summation md5; md5.Add(desc.data(), desc.size()); md5.Add("\n"); - return md5.Result(); + MD5Buffer = md5.Result(); + return StringView(MD5Buffer); } else if (likely(value.size() == 32)) { - MD5SumValue sumvalue; - if (sumvalue.Set(value)) - return sumvalue; - - _error->Error("Malformed Description-md5 line; includes invalid character '%.*s'", (int)value.length(), value.data()); - return MD5SumValue(); + return value; } _error->Error("Malformed Description-md5 line; doesn't have the required length (32 != %d) '%.*s'", (int)value.size(), (int)value.length(), value.data()); - return MD5SumValue(); + return StringView(); } /*}}}*/ // ListParser::UsePackage - Update a package structure /*{{{*/ |