Skip to content

[BOLT] Use StringRef::contains (NFC) #139658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

Once we convert EventNames to StringRef, which is cheap, we can call
StringRef::contains without creating a temporary instance of
std::string.

Once we convert EventNames to StringRef, which is cheap, we can call
StringRef::contains without creating a temporary instance of
std::string.
@llvmbot
Copy link
Member

llvmbot commented May 13, 2025

@llvm/pr-subscribers-bolt

Author: Kazu Hirata (kazutakahirata)

Changes

Once we convert EventNames to StringRef, which is cheap, we can call
StringRef::contains without creating a temporary instance of
std::string.


Full diff: https://github.com/llvm/llvm-project/pull/139658.diff

1 Files Affected:

  • (modified) bolt/lib/Profile/YAMLProfileReader.cpp (+1-1)
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index 821f8c3354f8b..33ce40ac2eeec 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -887,7 +887,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
 }
 
 bool YAMLProfileReader::usesEvent(StringRef Name) const {
-  return YamlBP.Header.EventNames.find(std::string(Name)) != StringRef::npos;
+  return StringRef(YamlBP.Header.EventNames).contains(Name);
 }
 
 } // end namespace bolt

@kazutakahirata kazutakahirata merged commit 383a825 into llvm:main May 13, 2025
12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_StringRef_contains_bolt branch May 13, 2025 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants