[llvm] r348650 - [ModuleSummary] use StringRefs to avoid a redundant copy; NFC
George Burgess IV via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 7 13:47:32 PST 2018
Author: gbiv
Date: Fri Dec 7 13:47:32 2018
New Revision: 348650
URL: http://llvm.org/viewvc/llvm-project?rev=348650&view=rev
Log:
[ModuleSummary] use StringRefs to avoid a redundant copy; NFC
`Saver` is a StringSaver, which has a few overloads of `save` that all
ultimately just call `StringRef save(StringRef)`. Just take a StringRef
here instead of building up a std::string to convert it to a StringRef.
Modified:
llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
Modified: llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h?rev=348650&r1=348649&r2=348650&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h (original)
+++ llvm/trunk/include/llvm/IR/ModuleSummaryIndex.h Fri Dec 7 13:47:32 2018
@@ -946,7 +946,7 @@ public:
// Save a string in the Index. Use before passing Name to
// getOrInsertValueInfo when the string isn't owned elsewhere (e.g. on the
// module's Strtab).
- StringRef saveString(std::string String) { return Saver.save(String); }
+ StringRef saveString(StringRef String) { return Saver.save(String); }
/// Return a ValueInfo for \p GUID setting value \p Name.
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID, StringRef Name) {
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=348650&r1=348649&r2=348650&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Dec 7 13:47:32 2018
@@ -4918,7 +4918,7 @@ void ModuleSummaryIndexBitcodeReader::se
ValueIdToValueInfoMap[ValueID] = std::make_pair(
TheIndex.getOrInsertValueInfo(
ValueGUID,
- UseStrtab ? ValueName : TheIndex.saveString(ValueName.str())),
+ UseStrtab ? ValueName : TheIndex.saveString(ValueName)),
OriginalNameID);
}
More information about the llvm-commits
mailing list