diff options
author | Alexander Shaposhnikov <shal1t712@gmail.com> | 2017-07-05 20:14:54 +0000 |
---|---|---|
committer | Alexander Shaposhnikov <shal1t712@gmail.com> | 2017-07-05 20:14:54 +0000 |
commit | d968f6f42377f6917b454b6508385f2f179b1f0c (patch) | |
tree | 4e300133dc975f79aa0f3d29f84357192cc8f18e /llvm/utils/TableGen/SearchableTableEmitter.cpp | |
parent | 8c4baa00de58e1f399cda78c5be5bd1fbb36c2b3 (diff) | |
download | bcm5719-llvm-d968f6f42377f6917b454b6508385f2f179b1f0c.tar.gz bcm5719-llvm-d968f6f42377f6917b454b6508385f2f179b1f0c.zip |
[tablegen] Avoid creating temporary strings
If a method / function returns a StringRef but the
variable is of type const std::string& a temporary string is
created (StringRef has a cast operator to std::string),
which is a suboptimal behavior.
Differential revision: https://reviews.llvm.org/D34994
Test plan: make check-all
llvm-svn: 307195
Diffstat (limited to 'llvm/utils/TableGen/SearchableTableEmitter.cpp')
-rw-r--r-- | llvm/utils/TableGen/SearchableTableEmitter.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp index efd4e83eca9..f73c197dee5 100644 --- a/llvm/utils/TableGen/SearchableTableEmitter.cpp +++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp @@ -230,7 +230,7 @@ void SearchableTableEmitter::emitLookupDeclaration(StringRef Name, void SearchableTableEmitter::emitMapping(Record *InstanceClass, raw_ostream &OS) { - const std::string &TableName = InstanceClass->getName(); + StringRef TableName = InstanceClass->getName(); std::vector<Record *> Items = Records.getAllDerivedDefinitions(TableName); // Gather all the records we're going to need for this particular mapping. @@ -265,8 +265,8 @@ void SearchableTableEmitter::emitMapping(Record *InstanceClass, ++Idx; } - OS << "#ifdef GET_" << StringRef(TableName).upper() << "_DECL\n"; - OS << "#undef GET_" << StringRef(TableName).upper() << "_DECL\n"; + OS << "#ifdef GET_" << TableName.upper() << "_DECL\n"; + OS << "#undef GET_" << TableName.upper() << "_DECL\n"; // Next emit the enum containing the top-level names for use in C++ code if // requested @@ -281,8 +281,8 @@ void SearchableTableEmitter::emitMapping(Record *InstanceClass, OS << "#endif\n\n"; - OS << "#ifdef GET_" << StringRef(TableName).upper() << "_IMPL\n"; - OS << "#undef GET_" << StringRef(TableName).upper() << "_IMPL\n"; + OS << "#ifdef GET_" << TableName.upper() << "_IMPL\n"; + OS << "#undef GET_" << TableName.upper() << "_IMPL\n"; // The primary data table contains all the fields defined for this map. emitPrimaryTable(TableName, FieldNames, SearchFieldNames, SearchTables, Items, |