[PATCH] D118612: [NFC] Move FoldingSetNodeIDRef::ComputeHash and FoldingSetNodeID::ComputeHash definitions to header
Dawid Jurczak via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 31 07:49:50 PST 2022
yurai007 created this revision.
yurai007 added reviewers: nikic, rsmith, xbolva00, serge-sans-paille, aeubanks, v.g.vassilev, ChuanqiXu.
Herald added subscribers: dexonsmith, hiraditya.
yurai007 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Lack of ComputeHash inlining slows down slightly FoldingSetBase::FindNodeOrInsertPos calls.
Inlining makes it faster which matters in particular for FoldingSet users in ASTContext.
Extracted from: https://reviews.llvm.org/D118385
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D118612
Files:
llvm/include/llvm/ADT/FoldingSet.h
llvm/lib/Support/FoldingSet.cpp
Index: llvm/lib/Support/FoldingSet.cpp
===================================================================
--- llvm/lib/Support/FoldingSet.cpp
+++ llvm/lib/Support/FoldingSet.cpp
@@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/FoldingSet.h"
-#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/ErrorHandling.h"
@@ -25,12 +24,6 @@
//===----------------------------------------------------------------------===//
// FoldingSetNodeIDRef Implementation
-/// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef,
-/// used to lookup the node in the FoldingSetBase.
-unsigned FoldingSetNodeIDRef::ComputeHash() const {
- return static_cast<unsigned>(hash_combine_range(Data, Data+Size));
-}
-
bool FoldingSetNodeIDRef::operator==(FoldingSetNodeIDRef RHS) const {
if (Size != RHS.Size) return false;
return memcmp(Data, RHS.Data, Size*sizeof(*Data)) == 0;
@@ -110,12 +103,6 @@
Bits.append(ID.Bits.begin(), ID.Bits.end());
}
-/// ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used to
-/// lookup the node in the FoldingSetBase.
-unsigned FoldingSetNodeID::ComputeHash() const {
- return FoldingSetNodeIDRef(Bits.data(), Bits.size()).ComputeHash();
-}
-
/// operator== - Used to compare two nodes to each other.
///
bool FoldingSetNodeID::operator==(const FoldingSetNodeID &RHS) const {
Index: llvm/include/llvm/ADT/FoldingSet.h
===================================================================
--- llvm/include/llvm/ADT/FoldingSet.h
+++ llvm/include/llvm/ADT/FoldingSet.h
@@ -15,6 +15,7 @@
#ifndef LLVM_ADT_FOLDINGSET_H
#define LLVM_ADT_FOLDINGSET_H
+#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/iterator.h"
#include "llvm/Support/Allocator.h"
@@ -292,7 +293,9 @@
/// ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef,
/// used to lookup the node in the FoldingSetBase.
- unsigned ComputeHash() const;
+ unsigned ComputeHash() const {
+ return static_cast<unsigned>(hash_combine_range(Data, Data + Size));
+ }
bool operator==(FoldingSetNodeIDRef) const;
@@ -362,7 +365,9 @@
/// ComputeHash - Compute a strong hash value for this FoldingSetNodeID, used
/// to lookup the node in the FoldingSetBase.
- unsigned ComputeHash() const;
+ unsigned ComputeHash() const {
+ return FoldingSetNodeIDRef(Bits.data(), Bits.size()).ComputeHash();
+ }
/// operator== - Used to compare two nodes to each other.
bool operator==(const FoldingSetNodeID &RHS) const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118612.404531.patch
Type: text/x-patch
Size: 2659 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220131/70780181/attachment.bin>
More information about the llvm-commits
mailing list