Skip to content

Commit c95745f

Browse files
[llvm] Use StringRef::{starts_with,find} (NFC) (llvm#139661)
Calling find/contains in the StringRef domain allows us to avoid creating temporary instances of std::string.
1 parent 294eb76 commit c95745f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ llvm::Error DwarfTransformer::verify(StringRef GsymPath,
780780
const auto &dii = DwarfInlineInfos.getFrame(Idx);
781781
gsymFilename = LR->getSourceFile(Idx);
782782
// Verify function name
783-
if (dii.FunctionName.find(gii.Name.str()) != 0)
783+
if (!StringRef(dii.FunctionName).starts_with(gii.Name))
784784
Out << "error: address " << HEX64(Addr) << " DWARF function \""
785785
<< dii.FunctionName.c_str()
786786
<< "\" doesn't match GSYM function \"" << gii.Name << "\"\n";

llvm/lib/TableGen/Record.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,11 +1796,11 @@ const Init *TernOpInit::Fold(const Record *CurRec) const {
17961796
if (LHSs && MHSs && RHSs) {
17971797
std::string Val = RHSs->getValue().str();
17981798

1799-
std::string::size_type found;
1800-
std::string::size_type idx = 0;
1799+
StringRef::size_type found;
1800+
StringRef::size_type idx = 0;
18011801
while (true) {
1802-
found = Val.find(LHSs->getValue().str(), idx);
1803-
if (found == std::string::npos)
1802+
found = StringRef(Val).find(LHSs->getValue(), idx);
1803+
if (found == StringRef::npos)
18041804
break;
18051805
Val.replace(found, LHSs->getValue().size(), MHSs->getValue().str());
18061806
idx = found + MHSs->getValue().size();

0 commit comments

Comments
 (0)