Просмотр исходного кода

pkgcache: Make hash arch-independent using fixed size integer

This helps writing test cases. Also adapt the test case that
expected 64-bit.

Nothing changes performance wise, the distribution of the hash
values remains intact.
Julian Andres Klode лет назад: 10
Родитель
Сommit
6755060951
2 измененных файлов с 3 добавлено и 3 удалено
  1. 2 2
      apt-pkg/pkgcache.cc
  2. 1 1
      test/integration/test-apt-cache

+ 2 - 2
apt-pkg/pkgcache.cc

@@ -203,7 +203,7 @@ bool pkgCache::ReMap(bool const &Errorchecks)
    table (480 used items) */
    table (480 used items) */
 map_id_t pkgCache::sHash(const string &Str) const
 map_id_t pkgCache::sHash(const string &Str) const
 {
 {
-   unsigned long Hash = 0;
+   uint32_t Hash = 0;
    for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
    for (string::const_iterator I = Str.begin(); I != Str.end(); ++I)
       Hash = 41 * Hash + tolower_ascii(*I);
       Hash = 41 * Hash + tolower_ascii(*I);
    return Hash % HeaderP->GetHashTableSize();
    return Hash % HeaderP->GetHashTableSize();
@@ -211,7 +211,7 @@ map_id_t pkgCache::sHash(const string &Str) const
 
 
 map_id_t pkgCache::sHash(const char *Str) const
 map_id_t pkgCache::sHash(const char *Str) const
 {
 {
-   unsigned long Hash = tolower_ascii(*Str);
+   uint32_t Hash = tolower_ascii(*Str);
    for (const char *I = Str + 1; *I != 0; ++I)
    for (const char *I = Str + 1; *I != 0; ++I)
       Hash = 41 * Hash + tolower_ascii(*I);
       Hash = 41 * Hash + tolower_ascii(*I);
    return Hash % HeaderP->GetHashTableSize();
    return Hash % HeaderP->GetHashTableSize();

+ 1 - 1
test/integration/test-apt-cache

@@ -48,8 +48,8 @@ testsuccess test -s dump.output
 
 
 testsuccessequal 'dpkg
 testsuccessequal 'dpkg
 bar
 bar
-specific
 fancy
 fancy
+specific
 foo' aptcache pkgnames
 foo' aptcache pkgnames
 testsuccessequal 'bar' aptcache pkgnames bar
 testsuccessequal 'bar' aptcache pkgnames bar
 testsuccessequal 'fancy
 testsuccessequal 'fancy