mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Force the DJB hash seed to 0 for compatibility with HashString.
The obsolete llvm::HashString() was equivalent to llvm::djbHash(seed=0) and was removed from llvm. This patch replaces all occurences of llvm::HashString() with llvm::djbHash(seed=0), no functional change. The default seed of llvm::djbHash() is supposed to yield a higher quality result that using seed=0, but changing it looks like it affects the ordering of SIL serialization.
This commit is contained in:
@@ -1055,7 +1055,8 @@ namespace {
|
||||
}
|
||||
|
||||
hash_value_type ComputeHash(key_type_ref key) {
|
||||
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second, 0);
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
|
||||
@@ -1298,7 +1299,8 @@ namespace {
|
||||
}
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second, 0);
|
||||
}
|
||||
|
||||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
|
||||
|
||||
@@ -169,7 +169,8 @@ public:
|
||||
return DenseMapInfo<uint64_t>::getHashValue(k.intValue.v0) &
|
||||
DenseMapInfo<uint64_t>::getHashValue(k.intValue.v1);
|
||||
case RawValueKey::Kind::String:
|
||||
return llvm::djbHash(k.stringValue);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(k.stringValue, 0);
|
||||
case RawValueKey::Kind::Empty:
|
||||
case RawValueKey::Kind::Tombstone:
|
||||
return 0;
|
||||
|
||||
@@ -103,7 +103,8 @@ public:
|
||||
external_key_type GetExternalKey(internal_key_type ID) { return ID; }
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
return llvm::djbHash(key);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key, 0);
|
||||
}
|
||||
|
||||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
|
||||
|
||||
@@ -318,7 +318,8 @@ public:
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
if (key.first == DeclBaseName::Kind::Normal) {
|
||||
return llvm::djbHash(key.second);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key.second, 0);
|
||||
} else {
|
||||
return (hash_value_type)key.first;
|
||||
}
|
||||
@@ -380,7 +381,8 @@ public:
|
||||
}
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
return llvm::djbHash(key);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key, 0);
|
||||
}
|
||||
|
||||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
|
||||
@@ -438,8 +440,9 @@ public:
|
||||
return ID;
|
||||
}
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
return llvm::djbHash(key);
|
||||
hash_value_type ComputeHash(iternal_key_type key) {
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key, 0);
|
||||
}
|
||||
|
||||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
|
||||
@@ -476,7 +479,8 @@ public:
|
||||
}
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
return llvm::djbHash(key);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key, 0);
|
||||
}
|
||||
|
||||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
|
||||
@@ -531,7 +535,8 @@ public:
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
if (key.first == DeclBaseName::Kind::Normal) {
|
||||
return llvm::djbHash(key.second);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key.second, 0);
|
||||
} else {
|
||||
return (hash_value_type)key.first;
|
||||
}
|
||||
@@ -704,7 +709,8 @@ public:
|
||||
}
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
return llvm::djbHash(key);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key, 0);
|
||||
}
|
||||
|
||||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
|
||||
@@ -891,7 +897,8 @@ public:
|
||||
|
||||
hash_value_type ComputeHash(internal_key_type key) {
|
||||
assert(!key.empty());
|
||||
return llvm::djbHash(key);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key, 0);
|
||||
}
|
||||
|
||||
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
|
||||
|
||||
@@ -101,7 +101,8 @@ namespace {
|
||||
switch (key.getKind()) {
|
||||
case DeclBaseName::Kind::Normal:
|
||||
assert(!key.empty());
|
||||
return llvm::djbHash(key.getIdentifier().str());
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key.getIdentifier().str(), 0);
|
||||
case DeclBaseName::Kind::Subscript:
|
||||
return static_cast<uint8_t>(DeclNameKind::Subscript);
|
||||
case DeclBaseName::Kind::Destructor:
|
||||
@@ -168,7 +169,8 @@ namespace {
|
||||
|
||||
hash_value_type ComputeHash(key_type_ref key) {
|
||||
assert(!key.empty());
|
||||
return llvm::djbHash(key.str());
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key.str(), 0);
|
||||
}
|
||||
|
||||
int32_t getNameDataForBase(const NominalTypeDecl *nominal,
|
||||
@@ -230,7 +232,8 @@ namespace {
|
||||
|
||||
hash_value_type ComputeHash(key_type_ref key) {
|
||||
assert(!key.empty());
|
||||
return llvm::djbHash(key);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key, 0);
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
|
||||
@@ -270,7 +273,8 @@ namespace {
|
||||
|
||||
hash_value_type ComputeHash(key_type_ref key) {
|
||||
assert(!key.empty());
|
||||
return llvm::djbHash(key.str());
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key.str(), 0);
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
|
||||
@@ -313,7 +317,8 @@ namespace {
|
||||
switch (key.getKind()) {
|
||||
case DeclBaseName::Kind::Normal:
|
||||
assert(!key.empty());
|
||||
return llvm::djbHash(key.getIdentifier().str());
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key.getIdentifier().str(), 0);
|
||||
case DeclBaseName::Kind::Subscript:
|
||||
return static_cast<uint8_t>(DeclNameKind::Subscript);
|
||||
case DeclBaseName::Kind::Destructor:
|
||||
@@ -4266,7 +4271,8 @@ public:
|
||||
|
||||
hash_value_type ComputeHash(key_type_ref key) {
|
||||
assert(!key.empty());
|
||||
return llvm::djbHash(key);
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key, 0);
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned>
|
||||
@@ -4637,7 +4643,8 @@ namespace {
|
||||
|
||||
hash_value_type ComputeHash(key_type_ref key) {
|
||||
llvm::SmallString<32> scratch;
|
||||
return llvm::djbHash(key.getString(scratch));
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key.getString(scratch), 0);
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
|
||||
|
||||
@@ -111,7 +111,8 @@ namespace {
|
||||
|
||||
hash_value_type ComputeHash(key_type_ref key) {
|
||||
assert(!key.empty());
|
||||
return llvm::djbHash(key.str());
|
||||
// FIXME: DJB seed=0, audit whether the default seed could be used.
|
||||
return llvm::djbHash(key.str(), 0);
|
||||
}
|
||||
|
||||
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
|
||||
|
||||
Reference in New Issue
Block a user