Skip to content

Commit c4dfa03

Browse files
[clang-tidy] Call StringMap::find without constructing std::string (NFC) (#115114)
StringMap::find takes StringRef, so we don't need to allocate temporary instances of std::string.
1 parent b7ee03f commit c4dfa03

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ std::optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
244244
{"ToDoubleNanoseconds", DurationScale::Nanoseconds},
245245
{"ToInt64Nanoseconds", DurationScale::Nanoseconds}});
246246

247-
auto ScaleIter = ScaleMap.find(std::string(Name));
247+
auto ScaleIter = ScaleMap.find(Name);
248248
if (ScaleIter == ScaleMap.end())
249249
return std::nullopt;
250250

@@ -260,7 +260,7 @@ std::optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name) {
260260
{"ToUnixMicros", DurationScale::Microseconds},
261261
{"ToUnixNanos", DurationScale::Nanoseconds}});
262262

263-
auto ScaleIter = ScaleMap.find(std::string(Name));
263+
auto ScaleIter = ScaleMap.find(Name);
264264
if (ScaleIter == ScaleMap.end())
265265
return std::nullopt;
266266

0 commit comments

Comments
 (0)