Skip to content

Commit

Permalink
[clangd] Use xxh3_64bits for background index file digests
Browse files Browse the repository at this point in the history
Many sources show that xxh3 is much better than xxh64. This particular
instance may or may not have noticeable difference, but this change
moves us toward removing xxHash64.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D155992
  • Loading branch information
MaskRay committed Jul 25, 2023
1 parent 61c7a91 commit 16d79d2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/SourceCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ TextEdit toTextEdit(const FixItHint &FixIt, const SourceManager &M,
}

FileDigest digest(llvm::StringRef Content) {
uint64_t Hash{llvm::xxHash64(Content)};
uint64_t Hash{llvm::xxh3_64bits(Content)};
FileDigest Result;
for (unsigned I = 0; I < Result.size(); ++I) {
Result[I] = uint8_t(Hash);
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/index/Background.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ static llvm::StringRef filenameWithoutExtension(llvm::StringRef Path) {

BackgroundQueue::Task BackgroundIndex::indexFileTask(std::string Path) {
std::string Tag = filenameWithoutExtension(Path).str();
uint64_t Key = llvm::xxHash64(Path);
uint64_t Key = llvm::xxh3_64bits(Path);
BackgroundQueue::Task T([this, Path(std::move(Path))] {
std::optional<WithContext> WithProvidedContext;
if (ContextProvider)
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/index/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ readCompileCommand(Reader CmdReader, llvm::ArrayRef<llvm::StringRef> Strings) {
// The current versioning scheme is simple - non-current versions are rejected.
// If you make a breaking change, bump this version number to invalidate stored
// data. Later we may want to support some backward compatibility.
constexpr static uint32_t Version = 18;
constexpr static uint32_t Version = 19;

llvm::Expected<IndexFileIn> readRIFF(llvm::StringRef Data,
SymbolOrigin Origin) {
Expand Down
Binary file not shown.

0 comments on commit 16d79d2

Please sign in to comment.