Don't create a new ParamAttrsList (which copies the vector) just to
authorChris Lattner <sabre@nondot.org>
Thu, 3 Jan 2008 00:29:27 +0000 (00:29 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 3 Jan 2008 00:29:27 +0000 (00:29 +0000)
get a profile.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45524 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ParameterAttributes.h
lib/VMCore/ParameterAttributes.cpp

index 05c3ebe939718d6982cd8efcd188346d0395143b..2b557bd684b932b4b128aff1e5da2d9c6fd7d66c 100644 (file)
@@ -266,7 +266,10 @@ class ParamAttrsList : public FoldingSetNode {
   /// @name Implementation Details
   /// @{
   public:
-    void Profile(FoldingSetNodeID &ID) const;
+    void Profile(FoldingSetNodeID &ID) const {
+      Profile(ID, attrs);
+    }
+    static void Profile(FoldingSetNodeID &ID, const ParamAttrsVector &Attrs);
     void dump() const;
 
   /// @}
index aaf80cd76581d098d2f6789b13c267a3ef4e9ea2..b6c29922a61eeba22bd0480b3cf841707d42a141 100644 (file)
@@ -106,9 +106,10 @@ ParamAttrsList::areCompatible(const ParamAttrsList *A, const ParamAttrsList *B){
   return true;
 }
 
-void ParamAttrsList::Profile(FoldingSetNodeID &ID) const {
-  for (unsigned i = 0; i < attrs.size(); ++i)
-    ID.AddInteger(unsigned(attrs[i].attrs) << 16 | unsigned(attrs[i].index));
+void ParamAttrsList::Profile(FoldingSetNodeID &ID,
+                             const ParamAttrsVector &Attrs) {
+  for (unsigned i = 0; i < Attrs.size(); ++i)
+    ID.AddInteger(unsigned(Attrs[i].attrs) << 16 | unsigned(Attrs[i].index));
 }
 
 const ParamAttrsList *
@@ -127,11 +128,10 @@ ParamAttrsList::get(const ParamAttrsVector &attrVec) {
 #endif
 
   // Otherwise, build a key to look up the existing attributes.
-  ParamAttrsList key(attrVec);
   FoldingSetNodeID ID;
-  key.Profile(ID);
+  ParamAttrsList::Profile(ID, attrVec);
   void *InsertPos;
-  ParamAttrsListPAL = ParamAttrsLists->FindNodeOrInsertPos(ID, InsertPos);
+  ParamAttrsList *PAL = ParamAttrsLists->FindNodeOrInsertPos(ID, InsertPos);
 
   // If we didn't find any existing attributes of the same shape then
   // create a new one and insert it.