[clang-tools-extra] [clang-tidy] Call StringMap::find without constructing std::string (NFC) (PR #115114)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 5 20:58:28 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
StringMap::find takes StringRef, so we don't need to allocate
temporary instances of std::string.
---
Full diff: https://github.com/llvm/llvm-project/pull/115114.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp (+2-2)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index 3d807c1d0f7aa2..4cdbbd43c14311 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -244,7 +244,7 @@ std::optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
{"ToDoubleNanoseconds", DurationScale::Nanoseconds},
{"ToInt64Nanoseconds", DurationScale::Nanoseconds}});
- auto ScaleIter = ScaleMap.find(std::string(Name));
+ auto ScaleIter = ScaleMap.find(Name);
if (ScaleIter == ScaleMap.end())
return std::nullopt;
@@ -260,7 +260,7 @@ std::optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name) {
{"ToUnixMicros", DurationScale::Microseconds},
{"ToUnixNanos", DurationScale::Nanoseconds}});
- auto ScaleIter = ScaleMap.find(std::string(Name));
+ auto ScaleIter = ScaleMap.find(Name);
if (ScaleIter == ScaleMap.end())
return std::nullopt;
``````````
</details>
https://github.com/llvm/llvm-project/pull/115114
More information about the cfe-commits
mailing list