Skip to content

Commit

Permalink
Remove unneeded string copy construction in StringIdMap (#8843)
Browse files Browse the repository at this point in the history
Summary:
A variable of type `std::string_view` can be directly assigned to a
variable of type `std::string`. There is no need to construct a
temporary variable first and then assign the value. The latter will
cause a redundant copy construction.

No functional changes.

Pull Request resolved: #8843

Reviewed By: kagamiori

Differential Revision: D54129489

Pulled By: Yuhta

fbshipit-source-id: 0288aa208ab4e4553087d13bc2d2b3f8d1d7d75c
  • Loading branch information
lingbin authored and facebook-github-bot committed Feb 23, 2024
1 parent a9baacf commit 3e4a26a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion velox/common/caching/StringIdMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ uint64_t StringIdMap::makeId(std::string_view string) {
return it->second;
}
Entry entry;
entry.string = std::string(string);
entry.string = string;
// Check that we do not use an id twice. In practice this never
// happens because the int64 counter would have to wrap around for
// this. Even if this happened, the time spent in the loop would
Expand Down

0 comments on commit 3e4a26a

Please sign in to comment.