diff options
author | ricea <ricea@chromium.org> | 2015-07-01 08:56:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-01 15:57:26 +0000 |
commit | a01edeadfb2c16eec6949ab6dcd502c84e13ac77 (patch) | |
tree | 3b7b5ef6fe77159bcdc428fa06e4187b01dedb3c /chromeos | |
parent | 1de79f036e95944a33cc0cc3d4e88f446b2f73cd (diff) | |
download | chromium_src-a01edeadfb2c16eec6949ab6dcd502c84e13ac77.zip chromium_src-a01edeadfb2c16eec6949ab6dcd502c84e13ac77.tar.gz chromium_src-a01edeadfb2c16eec6949ab6dcd502c84e13ac77.tar.bz2 |
Replace StringPrintf("%d", ...) with IntToString()
IntToString() is faster, more compact and clearer than
StringPrintf("%d", ...).
This CL reduces the size of the text segment of a Linux "Official" build by 1001 bytes.
This CL also adds a perftest to verify that IntToString() is faster than
StringPrintf("%d", ...).
Notes for reviewers:
* courgette/memory_monitor.cc contains LOG(INFO) statements. I bypassed presubmit rather than remove them.
* components/browser_watcher/watcher_client_win_unittest.cc passed a HANDLE through an int. I don't know why that worked on Win64. I have tried to make it 64-bit safe.
BUG=504372
TEST=compile, selected unit tests
TBR=stevenjb@chromium.org
NOPRESUBMIT=true
Review URL: https://codereview.chromium.org/1213443002
Cr-Commit-Position: refs/heads/master@{#337027}
Diffstat (limited to 'chromeos')
-rw-r--r-- | chromeos/network/geolocation_handler_unittest.cc | 5 | ||||
-rw-r--r-- | chromeos/network/network_util.cc | 4 |
2 files changed, 5 insertions, 4 deletions
diff --git a/chromeos/network/geolocation_handler_unittest.cc b/chromeos/network/geolocation_handler_unittest.cc index 97c6ac7..265f120 100644 --- a/chromeos/network/geolocation_handler_unittest.cc +++ b/chromeos/network/geolocation_handler_unittest.cc @@ -4,6 +4,7 @@ #include "base/memory/scoped_ptr.h" #include "base/message_loop/message_loop.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "base/values.h" #include "chromeos/dbus/dbus_thread_manager.h" @@ -48,8 +49,8 @@ class GeolocationHandlerTest : public testing::Test { std::string mac_address = base::StringPrintf("%02X:%02X:%02X:%02X:%02X:%02X", idx, 0, 0, 0, 0, 0); - std::string channel = base::StringPrintf("%d", idx); - std::string strength = base::StringPrintf("%d", idx * 10); + std::string channel = base::IntToString(idx); + std::string strength = base::IntToString(idx * 10); properties.SetStringWithoutPathExpansion( shill::kGeoMacAddressProperty, mac_address); properties.SetStringWithoutPathExpansion( diff --git a/chromeos/network/network_util.cc b/chromeos/network/network_util.cc index 5fa7de5..54a619a 100644 --- a/chromeos/network/network_util.cc +++ b/chromeos/network/network_util.cc @@ -4,9 +4,9 @@ #include "chromeos/network/network_util.h" +#include "base/strings/string_number_conversions.h" #include "base/strings/string_tokenizer.h" #include "base/strings/string_util.h" -#include "base/strings/stringprintf.h" #include "chromeos/login/login_state.h" #include "chromeos/network/device_state.h" #include "chromeos/network/managed_network_configuration_handler.h" @@ -54,7 +54,7 @@ std::string PrefixLengthToNetmask(int32 prefix_length) { netmask += "."; int value = remainder == 0 ? 0 : ((2L << (remainder - 1)) - 1) << (8 - remainder); - netmask += base::StringPrintf("%d", value); + netmask += base::IntToString(value); } return netmask; } |