[llvm] d1b5708 - DetailedRecordsBackend.cpp - printSectionHeading - avoid std::string creation/copies.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 13 08:53:25 PDT 2021


Author: Simon Pilgrim
Date: 2021-06-13T16:49:40+01:00
New Revision: d1b57086d55afcfa94711a0b09c22a4113f6261f

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

LOG: DetailedRecordsBackend.cpp - printSectionHeading - avoid std::string creation/copies.

Don't create std::string from constant c-strings or pass std::string by value - we can use StringRef instead.

Added: 
    

Modified: 
    llvm/lib/TableGen/DetailedRecordsBackend.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/TableGen/DetailedRecordsBackend.cpp b/llvm/lib/TableGen/DetailedRecordsBackend.cpp
index c336a913199d..e181f79b903d 100644
--- a/llvm/lib/TableGen/DetailedRecordsBackend.cpp
+++ b/llvm/lib/TableGen/DetailedRecordsBackend.cpp
@@ -45,7 +45,7 @@ class DetailedRecordsEmitter {
   void printVariables(raw_ostream &OS);
   void printClasses(raw_ostream &OS);
   void printRecords(raw_ostream &OS);
-  void printSectionHeading(std::string Title, int Count, raw_ostream &OS);
+  void printSectionHeading(StringRef Title, int Count, raw_ostream &OS);
   void printDefms(Record *Rec, raw_ostream &OS);
   void printTemplateArgs(Record *Rec, raw_ostream &OS);
   void printSuperclasses(Record *Rec, raw_ostream &OS);
@@ -113,7 +113,7 @@ void DetailedRecordsEmitter::printRecords(raw_ostream &OS) {
 
 // Print a section heading with the name of the section and
 // the item count.
-void DetailedRecordsEmitter::printSectionHeading(std::string Title, int Count,
+void DetailedRecordsEmitter::printSectionHeading(StringRef Title, int Count,
                                                  raw_ostream &OS) {
   OS << formatv("\n{0} {1} ({2}) {0}\n", "--------------------", Title, Count);
 }


        


More information about the llvm-commits mailing list