Replace libchrome NumberToString with std::format
Replaces NumberToString in <base/string/string_number_conversions.h>
with std::format().
This change is very mechanical, no change in program behavior.
Test: build
Bug: 360917504
Change-Id: Iad92c9d4f4426790d8c38943147dede6eb873cb1
diff --git a/common/cpu_limiter.cc b/common/cpu_limiter.cc
index 5f1ae6f..3226390 100644
--- a/common/cpu_limiter.cc
+++ b/common/cpu_limiter.cc
@@ -20,7 +20,6 @@
#include <base/bind.h>
#include <base/logging.h>
-#include <base/strings/string_number_conversions.h>
#include <base/time/time.h>
#include "update_engine/common/utils.h"
@@ -67,7 +66,7 @@
if (shares_ == shares)
return true;
- std::string string_shares = base::NumberToString(static_cast<int>(shares));
+ std::string string_shares = std::format("{}", static_cast<int>(shares));
LOG(INFO) << "Setting cgroup cpu shares to " << string_shares;
if (!utils::WriteFile(
kCGroupSharesPath, string_shares.c_str(), string_shares.size())) {
diff --git a/common/error_code_utils.cc b/common/error_code_utils.cc
index 421e124..dc2d7cb 100644
--- a/common/error_code_utils.cc
+++ b/common/error_code_utils.cc
@@ -16,8 +16,6 @@
#include "update_engine/common/error_code_utils.h"
-#include <base/strings/string_number_conversions.h>
-
using std::string;
namespace chromeos_update_engine {
@@ -185,7 +183,7 @@
// error codes which should be added here.
}
- return "Unknown error: " + base::NumberToString(static_cast<unsigned>(code));
+ return "Unknown error: " + std::format("{}", static_cast<unsigned>(code));
}
} // namespace utils
diff --git a/common/prefs.cc b/common/prefs.cc
index 8a727ae..a65ce51 100644
--- a/common/prefs.cc
+++ b/common/prefs.cc
@@ -25,7 +25,6 @@
#include <base/files/file_enumerator.h>
#include <base/files/file_util.h>
#include <base/logging.h>
-#include <base/strings/string_number_conversions.h>
#include <base/strings/string_split.h>
#include <base/strings/string_util.h>
@@ -89,7 +88,7 @@
}
bool PrefsBase::SetInt64(std::string_view key, const int64_t value) {
- return SetString(key, base::NumberToString(value));
+ return SetString(key, std::format("{}", value));
}
bool PrefsBase::GetBoolean(std::string_view key, bool* value) const {
diff --git a/common/utils.cc b/common/utils.cc
index 7baddab..180c7b4 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -1204,7 +1204,7 @@
}
string GetExclusionName(const string& str_to_convert) {
- return base::NumberToString(base::StringPieceHash()(str_to_convert));
+ return std::format("{}", base::StringPieceHash()(str_to_convert));
}
static bool ParseTimestamp(std::string_view str, int64_t* out) {
diff --git a/payload_consumer/install_plan.cc b/payload_consumer/install_plan.cc
index f5cab45..58558f9 100644
--- a/payload_consumer/install_plan.cc
+++ b/payload_consumer/install_plan.cc
@@ -109,12 +109,12 @@
result_str.emplace_back(VectorToString(
{
{"Partition", partition.name},
- {"source_size", base::NumberToString(partition.source_size)},
+ {"source_size", std::format("{}", partition.source_size)},
{"source_path", partition.source_path},
{"source_hash",
base::HexEncode(partition.source_hash.data(),
partition.source_hash.size())},
- {"target_size", base::NumberToString(partition.target_size)},
+ {"target_size", std::format("{}", partition.target_size)},
{"target_path", partition.target_path},
{"target_hash",
base::HexEncode(partition.target_hash.data(),
@@ -131,10 +131,10 @@
const auto& payload = payloads[i];
result_str.emplace_back(VectorToString(
{
- {"Payload", base::NumberToString(i)},
+ {"Payload", std::format("{}", i)},
{"urls", PayloadUrlsToString(payload.payload_urls)},
- {"size", base::NumberToString(payload.size)},
- {"metadata_size", base::NumberToString(payload.metadata_size)},
+ {"size", std::format("{}", payload.size)},
+ {"metadata_size", std::format("{}", payload.metadata_size)},
{"metadata_signature", payload.metadata_signature},
{"hash", base::HexEncode(payload.hash.data(), payload.hash.size())},
{"type", InstallPayloadTypeToString(payload.type)},
diff --git a/update_status_utils.cc b/update_status_utils.cc
index 6b96dda..6b23d4f 100644
--- a/update_status_utils.cc
+++ b/update_status_utils.cc
@@ -16,7 +16,6 @@
#include "update_engine/update_status_utils.h"
#include <base/logging.h>
-#include <base/strings/string_number_conversions.h>
#include <brillo/key_value_store.h>
using brillo::KeyValueStore;
@@ -98,10 +97,9 @@
KeyValueStore key_value_store;
key_value_store.SetString(kLastCheckedTime,
- base::NumberToString(status.last_checked_time));
- key_value_store.SetString(kProgress, base::NumberToString(status.progress));
- key_value_store.SetString(kNewSize,
- base::NumberToString(status.new_size_bytes));
+ std::format("{}", status.last_checked_time));
+ key_value_store.SetString(kProgress, std::format("{}", status.progress));
+ key_value_store.SetString(kNewSize, std::format("{}", status.new_size_bytes));
key_value_store.SetString(kCurrentOp, UpdateStatusToString(status.status));
key_value_store.SetString(kNewVersion, status.new_version);
key_value_store.SetBoolean(kIsEnterpriseRollback,