|
23 | 23 | #include <fstream> |
24 | 24 | #include <optional> |
25 | 25 | #include <string> |
| 26 | +#include <string_view> |
26 | 27 | #include <utility> |
27 | 28 | #include <vector> |
28 | 29 |
|
29 | | -#include <android-base/logging.h> |
30 | | -#include <android-base/strings.h> |
31 | | -#include <fmt/core.h> |
32 | | -#include <fmt/format.h> |
33 | | -#include <json/config.h> |
34 | | -#include <json/reader.h> |
35 | | -#include <json/value.h> |
36 | | - |
37 | | -#include <google/protobuf/text_format.h> |
| 30 | +#include "absl/strings/str_cat.h" |
| 31 | +#include "android-base/logging.h" |
| 32 | +#include "android-base/strings.h" |
| 33 | +#include "fmt/core.h" |
| 34 | +#include "fmt/format.h" |
| 35 | +#include "google/protobuf/text_format.h" |
| 36 | +#include "json/config.h" |
| 37 | +#include "json/reader.h" |
| 38 | +#include "json/value.h" |
38 | 39 |
|
39 | 40 | #include "cuttlefish/common/libs/utils/device_type.h" |
40 | 41 | #include "cuttlefish/common/libs/utils/files.h" |
41 | 42 | #include "cuttlefish/common/libs/utils/flags_validator.h" |
42 | 43 | #include "cuttlefish/common/libs/utils/host_info.h" |
43 | 44 | #include "cuttlefish/common/libs/utils/result.h" |
| 45 | +#include "cuttlefish/host/commands/assemble_cvd/proto/guest_config.pb.h" |
44 | 46 | #include "cuttlefish/host/libs/config/ap_boot_flow.h" |
45 | 47 | #include "cuttlefish/host/libs/config/boot_flow.h" |
46 | 48 | #include "cuttlefish/host/libs/config/config_constants.h" |
47 | 49 | #include "cuttlefish/host/libs/config/external_network_mode.h" |
48 | 50 | #include "cuttlefish/host/libs/config/guest_hwui_renderer.h" |
49 | 51 | #include "cuttlefish/host/libs/config/guest_renderer_preload.h" |
50 | 52 |
|
51 | | -#include "cuttlefish/host/commands/assemble_cvd/proto/guest_config.pb.h" |
52 | | - |
53 | 53 | namespace cuttlefish { |
54 | 54 | namespace { |
55 | 55 |
|
@@ -1915,8 +1915,8 @@ bool CuttlefishConfig::InstanceSpecific::enable_tap_devices() const { |
1915 | 1915 |
|
1916 | 1916 | std::string CuttlefishConfig::InstanceSpecific::touch_socket_path( |
1917 | 1917 | int touch_dev_idx) const { |
1918 | | - return PerInstanceInternalUdsPath( |
1919 | | - ("touch_" + std::to_string(touch_dev_idx) + ".sock").c_str()); |
| 1918 | + std::string name = absl::StrCat("touch_", touch_dev_idx, ".sock"); |
| 1919 | + return PerInstanceInternalUdsPath(name); |
1920 | 1920 | } |
1921 | 1921 |
|
1922 | 1922 | std::string CuttlefishConfig::InstanceSpecific::mouse_socket_path() const { |
@@ -2004,53 +2004,53 @@ CuttlefishConfig::InstanceSpecific::audio_settings() const { |
2004 | 2004 | } |
2005 | 2005 |
|
2006 | 2006 | std::string CuttlefishConfig::InstanceSpecific::PerInstancePath( |
2007 | | - const std::string& file_name) const { |
2008 | | - return (instance_dir() + "/") + file_name; |
| 2007 | + std::string_view file_name) const { |
| 2008 | + return absl::StrCat(instance_dir(), "/", file_name); |
2009 | 2009 | } |
2010 | 2010 |
|
2011 | 2011 | std::string CuttlefishConfig::InstanceSpecific::PerInstanceInternalPath( |
2012 | | - const std::string& file_name) const { |
2013 | | - if (file_name[0] == '\0') { |
| 2012 | + std::string_view file_name) const { |
| 2013 | + if (file_name.empty()) { |
2014 | 2014 | // Don't append a / if file_name is empty. |
2015 | 2015 | return PerInstancePath(kInternalDirName); |
2016 | 2016 | } |
2017 | | - auto relative_path = (std::string(kInternalDirName) + "/") + file_name; |
2018 | | - return PerInstancePath(relative_path.c_str()); |
| 2017 | + std::string relative_path = absl::StrCat(kInternalDirName, "/", file_name); |
| 2018 | + return PerInstancePath(relative_path); |
2019 | 2019 | } |
2020 | 2020 |
|
2021 | 2021 | std::string CuttlefishConfig::InstanceSpecific::PerInstanceUdsPath( |
2022 | | - const std::string& file_name) const { |
2023 | | - return (instance_uds_dir() + "/") + file_name; |
| 2022 | + std::string_view file_name) const { |
| 2023 | + return absl::StrCat(instance_uds_dir(), "/", file_name); |
2024 | 2024 | } |
2025 | 2025 |
|
2026 | 2026 | std::string CuttlefishConfig::InstanceSpecific::PerInstanceInternalUdsPath( |
2027 | | - const std::string& file_name) const { |
2028 | | - if (file_name[0] == '\0') { |
| 2027 | + std::string_view file_name) const { |
| 2028 | + if (file_name.empty()) { |
2029 | 2029 | // Don't append a / if file_name is empty. |
2030 | 2030 | return PerInstanceUdsPath(kInternalDirName); |
2031 | 2031 | } |
2032 | | - auto relative_path = (std::string(kInternalDirName) + "/") + file_name; |
2033 | | - return PerInstanceUdsPath(relative_path.c_str()); |
| 2032 | + std::string relative_path = absl::StrCat(kInternalDirName, "/", file_name); |
| 2033 | + return PerInstanceUdsPath(relative_path); |
2034 | 2034 | } |
2035 | 2035 |
|
2036 | 2036 | std::string CuttlefishConfig::InstanceSpecific::PerInstanceGrpcSocketPath( |
2037 | | - const std::string& socket_name) const { |
| 2037 | + std::string_view socket_name) const { |
2038 | 2038 | if (socket_name.empty()) { |
2039 | 2039 | // Don't append a / if file_name is empty. |
2040 | 2040 | return PerInstanceUdsPath(kGrpcSocketDirName); |
2041 | 2041 | } |
2042 | | - auto relative_path = (std::string(kGrpcSocketDirName) + "/") + socket_name; |
2043 | | - return PerInstanceUdsPath(relative_path.c_str()); |
| 2042 | + std::string rel_path = absl::StrCat(kGrpcSocketDirName, "/", socket_name); |
| 2043 | + return PerInstanceUdsPath(rel_path); |
2044 | 2044 | } |
2045 | 2045 |
|
2046 | 2046 | std::string CuttlefishConfig::InstanceSpecific::PerInstanceLogPath( |
2047 | | - const std::string& file_name) const { |
| 2047 | + std::string_view file_name) const { |
2048 | 2048 | if (file_name.empty()) { |
2049 | 2049 | // Don't append a / if file_name is empty. |
2050 | 2050 | return PerInstancePath(kLogDirName); |
2051 | 2051 | } |
2052 | | - auto relative_path = (std::string(kLogDirName) + "/") + file_name; |
2053 | | - return PerInstancePath(relative_path.c_str()); |
| 2052 | + std::string relative_path = absl::StrCat(kLogDirName, "/", file_name); |
| 2053 | + return PerInstancePath(relative_path); |
2054 | 2054 | } |
2055 | 2055 |
|
2056 | 2056 | std::string CuttlefishConfig::InstanceSpecific::instance_name() const { |
|
0 commit comments