[PyTorch] Remove unnecessary std::string in Device.cpp (#61502)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/61502
No reason not to use string literals here.
ghstack-source-id: 133449808
Test Plan: buildsizebot
Reviewed By: dhruvbird
Differential Revision: D29648079
fbshipit-source-id: 74ecf12283c2f196b4b3edb75c6bb1eeed51322e
diff --git a/c10/core/Device.cpp b/c10/core/Device.cpp
index 68ddd53..82cfc3c 100644
--- a/c10/core/Device.cpp
+++ b/c10/core/Device.cpp
@@ -30,7 +30,7 @@
namespace {
DeviceType parse_type(const std::string& device_string) {
static const std::array<
- std::pair<std::string, DeviceType>,
+ std::pair<const char*, DeviceType>,
static_cast<size_t>(DeviceType::COMPILE_TIME_MAX_DEVICE_TYPES)>
types = {{
{"cpu", DeviceType::CPU},
@@ -53,8 +53,8 @@
auto device = std::find_if(
types.begin(),
types.end(),
- [device_string](const std::pair<std::string, DeviceType>& p) {
- return p.first == device_string;
+ [&device_string](const std::pair<const char*, DeviceType>& p) {
+ return p.first && p.first == device_string;
});
if (device != types.end()) {
return device->second;