summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-01-17 14:34:45 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2020-02-18 13:39:26 +0100
commit8c10048dce06ee0f160c86a6df07f0e6d2c34242 (patch)
tree7d18b03a24c3ce41c76904cd6ccb8430e7638dc4 /apt-pkg/deb
parent62683ed6459e874119f3346d8be66b85e8a90533 (diff)
Use a 32-bit djb VersionHash instead of CRC-16
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc8
-rw-r--r--apt-pkg/deb/deblistparser.h4
2 files changed, 6 insertions, 6 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 7614423df..33c83f8f0 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -339,7 +339,7 @@ bool debListParser::UsePackage(pkgCache::PkgIterator &Pkg,
// ListParser::VersionHash - Compute a unique hash for this version /*{{{*/
// ---------------------------------------------------------------------
/* */
-unsigned short debListParser::VersionHash()
+uint32_t debListParser::VersionHash()
{
static constexpr pkgTagSection::Key Sections[] ={
pkgTagSection::Key::Installed_Size,
@@ -350,7 +350,7 @@ unsigned short debListParser::VersionHash()
pkgTagSection::Key::Conflicts,
pkgTagSection::Key::Breaks,
pkgTagSection::Key::Replaces};
- unsigned long Result = INIT_FCS;
+ unsigned long Result = 5381;
for (auto I : Sections)
{
const char *Start;
@@ -371,7 +371,7 @@ unsigned short debListParser::VersionHash()
}
if (isspace_ascii(*Start) != 0 || *Start == '=')
continue;
- Result = AddCRC16Byte(Result, tolower_ascii_unsafe(*Start));
+ Result = 33 * Result + tolower_ascii_unsafe(*Start);
}
@@ -991,7 +991,7 @@ unsigned char debListParser::GetPrio(string Str)
return Out;
}
/*}}}*/
-bool debListParser::SameVersion(unsigned short const Hash, /*{{{*/
+bool debListParser::SameVersion(uint32_t Hash, /*{{{*/
pkgCache::VerIterator const &Ver)
{
if (pkgCacheListParser::SameVersion(Hash, Ver) == false)
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index a04187c45..eefce2a6a 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -64,8 +64,8 @@ class APT_HIDDEN debListParser : public pkgCacheListParser
virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
virtual APT::StringView Description_md5() APT_OVERRIDE;
- virtual unsigned short VersionHash() APT_OVERRIDE;
- virtual bool SameVersion(unsigned short const Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
+ virtual uint32_t VersionHash() APT_OVERRIDE;
+ virtual bool SameVersion(uint32_t Hash, pkgCache::VerIterator const &Ver) APT_OVERRIDE;
virtual bool UsePackage(pkgCache::PkgIterator &Pkg,
pkgCache::VerIterator &Ver) APT_OVERRIDE;
virtual map_filesize_t Offset() APT_OVERRIDE {return iOffset;};