[clang-tools-extra] r321302 - [clangd] Don't re-hash SymbolID in maps, just use the SHA1 data
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 21 12:11:46 PST 2017
Author: sammccall
Date: Thu Dec 21 12:11:46 2017
New Revision: 321302
URL: http://llvm.org/viewvc/llvm-project?rev=321302&view=rev
Log:
[clangd] Don't re-hash SymbolID in maps, just use the SHA1 data
Modified:
clang-tools-extra/trunk/clangd/index/Index.cpp
clang-tools-extra/trunk/clangd/index/Index.h
Modified: clang-tools-extra/trunk/clangd/index/Index.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.cpp?rev=321302&r1=321301&r2=321302&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Index.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/Index.cpp Thu Dec 21 12:11:46 2017
@@ -24,7 +24,7 @@ llvm::raw_ostream &operator<<(llvm::raw_
void operator>>(llvm::StringRef Str, SymbolID &ID) {
std::string HexString = fromHex(Str);
- assert(HexString.size() == 20);
+ assert(HexString.size() == ID.HashValue.size());
std::copy(HexString.begin(), HexString.end(), ID.HashValue.begin());
}
Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=321302&r1=321301&r2=321302&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Thu Dec 21 12:11:46 2017
@@ -52,7 +52,9 @@ public:
private:
friend llvm::hash_code hash_value(const SymbolID &ID) {
- return hash_value(ArrayRef<uint8_t>(ID.HashValue));
+ // We already have a good hash, just return the first bytes.
+ static_assert(sizeof(size_t) <= 20, "size_t longer than SHA1!");
+ return *reinterpret_cast<const size_t *>(ID.HashValue.data());
}
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
const SymbolID &ID);
More information about the cfe-commits
mailing list