aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-13 18:25:44 +0000
committerDan Gohman <gohman@apple.com>2009-07-13 18:25:44 +0000
commitd6a2aab53e3c4fcd53399cfa6f66d62913e53663 (patch)
treec514f314b1b0b65c66abddf23472a0826da627b3 /include
parentd2559bf3f30cc7400483825414489ec0fb36481a (diff)
downloadexternal_llvm-d6a2aab53e3c4fcd53399cfa6f66d62913e53663.zip
external_llvm-d6a2aab53e3c4fcd53399cfa6f66d62913e53663.tar.gz
external_llvm-d6a2aab53e3c4fcd53399cfa6f66d62913e53663.tar.bz2
Add an optional optimization to FoldingSet to allow ID values to be
stored rather than recomputed on each bucket traversal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/FoldingSet.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/llvm/ADT/FoldingSet.h b/include/llvm/ADT/FoldingSet.h
index 1bcff3d..1465d04 100644
--- a/include/llvm/ADT/FoldingSet.h
+++ b/include/llvm/ADT/FoldingSet.h
@@ -439,6 +439,20 @@ public:
};
//===----------------------------------------------------------------------===//
+/// FastFoldingSetNode - This is a subclass of FoldingSetNode which stores
+/// a FoldingSetNodeID value rather than requiring the node to recompute it
+/// each time it is needed. This trades space for speed (which can be
+/// significant if the ID is long), and it also permits nodes to drop
+/// information that would otherwise only be required for recomputing an ID.
+class FastFoldingSetNode : public FoldingSetNode {
+ FoldingSetNodeID FastID;
+protected:
+ explicit FastFoldingSetNode(const FoldingSetNodeID &ID) : FastID(ID) {}
+public:
+ void Profile(FoldingSetNodeID& ID) { ID = FastID; }
+};
+
+//===----------------------------------------------------------------------===//
// Partial specializations of FoldingSetTrait.
template<typename T> struct FoldingSetTrait<T*> {