mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user