[llvm-branch-commits] [llvm] bd343d2 - [TableGen] Return const std::string& in InstrMap getName()/getFilterClass() methods. NFCI.

Simon Pilgrim via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 17 07:27:35 PST 2020


Author: Simon Pilgrim
Date: 2020-12-17T15:23:03Z
New Revision: bd343d26814640b4934fdde8637ad5577d30c83c

URL: https://github.com/llvm/llvm-project/commit/bd343d26814640b4934fdde8637ad5577d30c83c
DIFF: https://github.com/llvm/llvm-project/commit/bd343d26814640b4934fdde8637ad5577d30c83c.diff

LOG: [TableGen] Return const std::string& in InstrMap getName()/getFilterClass() methods. NFCI.

Avoid temp std::string instances - we're never keeping these around, just printing them to streams, converting to StringRef etc.

Added: 
    

Modified: 
    llvm/utils/TableGen/CodeGenMapTable.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/CodeGenMapTable.cpp b/llvm/utils/TableGen/CodeGenMapTable.cpp
index 57d86a8fc119..ea53a2d3eee6 100644
--- a/llvm/utils/TableGen/CodeGenMapTable.cpp
+++ b/llvm/utils/TableGen/CodeGenMapTable.cpp
@@ -144,9 +144,9 @@ class InstrMap {
     }
   }
 
-  std::string getName() const { return Name; }
+  const std::string &getName() const { return Name; }
 
-  std::string getFilterClass() const { return FilterClass; }
+  const std::string &getFilterClass() const { return FilterClass; }
 
   ListInit *getRowFields() const { return RowFields; }
 
@@ -190,7 +190,7 @@ class MapTableEmitter {
 public:
   MapTableEmitter(CodeGenTarget &Target, RecordKeeper &Records, Record *IMRec):
                   Target(Target), InstrMapDesc(IMRec) {
-    const std::string FilterClass = InstrMapDesc.getFilterClass();
+    const std::string &FilterClass = InstrMapDesc.getFilterClass();
     InstrDefs = Records.getAllDerivedDefinitions(FilterClass);
   }
 


        


More information about the llvm-branch-commits mailing list