[llvm] 61a286a - [tools] Don't call StringRef::str() when calling StringMap::find (NFC) (#113119)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 06:50:37 PDT 2024
Author: Kazu Hirata
Date: 2024-10-21T06:50:34-07:00
New Revision: 61a286ac0817671ad09a505303b7a3a446798316
URL: https://github.com/llvm/llvm-project/commit/61a286ac0817671ad09a505303b7a3a446798316
DIFF: https://github.com/llvm/llvm-project/commit/61a286ac0817671ad09a505303b7a3a446798316.diff
LOG: [tools] Don't call StringRef::str() when calling StringMap::find (NFC) (#113119)
StringMap::find takes StringRef. We don't need to create an instance
of std::string from StringRef only to convert it right back to
StringRef.
Added:
Modified:
llvm/tools/llvm-profdata/llvm-profdata.cpp
llvm/tools/llvm-readtapi/llvm-readtapi.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index c235c3f2b105e1..59f0f1f1fae899 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -1297,7 +1297,7 @@ adjustInstrProfile(std::unique_ptr<WriterContext> &WC,
} else {
auto NewName = StaticFuncMap.find(Name);
if (NewName != StaticFuncMap.end()) {
- It = InstrProfileMap.find(NewName->second.str());
+ It = InstrProfileMap.find(NewName->second);
if (NewName->second != DuplicateNameStr) {
NewRootName = &NewName->second;
}
@@ -1382,7 +1382,7 @@ adjustInstrProfile(std::unique_ptr<WriterContext> &WC,
if (It == InstrProfileMap.end()) {
auto NewName = StaticFuncMap.find(Name);
if (NewName != StaticFuncMap.end()) {
- It = InstrProfileMap.find(NewName->second.str());
+ It = InstrProfileMap.find(NewName->second);
if (NewName->second == DuplicateNameStr) {
WithColor::warning()
<< "Static function " << Name
diff --git a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
index 1d740109d5b679..7390d0ec4b79a3 100644
--- a/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
+++ b/llvm/tools/llvm-readtapi/llvm-readtapi.cpp
@@ -382,7 +382,7 @@ static void stubifyDirectory(const StringRef InputPath, Context &Ctx) {
// libraries to stubify.
StringRef LibToCheck = Found->second;
for (int i = 0; i < 20; ++i) {
- auto LinkIt = SymLinks.find(LibToCheck.str());
+ auto LinkIt = SymLinks.find(LibToCheck);
if (LinkIt != SymLinks.end()) {
for (auto &SymInfo : LinkIt->second) {
SmallString<PATH_MAX> LinkSrc(SymInfo.SrcPath);
More information about the llvm-commits
mailing list