[llvm] r276737 - [tblgen] Compare const char * with strcmp instead of creating StringRef.
Benjamin Kramer via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 02:27:51 PDT 2016
Author: d0k
Date: Tue Jul 26 04:27:51 2016
New Revision: 276737
URL: http://llvm.org/viewvc/llvm-project?rev=276737&view=rev
Log:
[tblgen] Compare const char * with strcmp instead of creating StringRef.
Avoids a call to strlen on both strings which always reads the entire
string. strcmp can use early exit.
Modified:
llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp
Modified: llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp?rev=276737&r1=276736&r2=276737&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/SearchableTableEmitter.cpp Tue Jul 26 04:27:51 2016
@@ -193,7 +193,7 @@ void SearchableTableEmitter::emitLookupF
} else {
// Make sure the result is null terminated because it's going via "char *".
OS << " std::string CanonicalVal = " << Field << ".upper();\n";
- OS << " " << PairType << " Val = {CanonicalVal.data(), 0};\n";
+ OS << " " << PairType << " Val = {CanonicalVal.c_str(), 0};\n";
}
OS << " ArrayRef<" << PairType << "> Table(" << Name << "sBy" << Field
@@ -206,7 +206,7 @@ void SearchableTableEmitter::emitLookupF
OS << ",\n ";
OS << "[](const " << PairType << " &LHS, const " << PairType
<< " &RHS) {\n";
- OS << " return StringRef(LHS.first) < StringRef(RHS.first);\n";
+ OS << " return std::strcmp(LHS.first, RHS.first) < 0;\n";
OS << " });\n\n";
}
More information about the llvm-commits
mailing list