[llvm-commits] [llvm] r75480 - /llvm/trunk/include/llvm/ADT/FoldingSet.h

Dan Gohman gohman at apple.com
Mon Jul 13 11:25:44 PDT 2009


Author: djg
Date: Mon Jul 13 13:25:44 2009
New Revision: 75480

URL: http://llvm.org/viewvc/llvm-project?rev=75480&view=rev
Log:
Add an optional optimization to FoldingSet to allow ID values to be
stored rather than recomputed on each bucket traversal.

Modified:
    llvm/trunk/include/llvm/ADT/FoldingSet.h

Modified: llvm/trunk/include/llvm/ADT/FoldingSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FoldingSet.h?rev=75480&r1=75479&r2=75480&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/FoldingSet.h (original)
+++ llvm/trunk/include/llvm/ADT/FoldingSet.h Mon Jul 13 13:25:44 2009
@@ -439,6 +439,20 @@
 };
 
 //===----------------------------------------------------------------------===//
+/// 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*> {





More information about the llvm-commits mailing list