summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorricea <ricea@chromium.org>2015-07-01 08:56:50 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-01 15:57:26 +0000
commita01edeadfb2c16eec6949ab6dcd502c84e13ac77 (patch)
tree3b7b5ef6fe77159bcdc428fa06e4187b01dedb3c /net/disk_cache
parent1de79f036e95944a33cc0cc3d4e88f446b2f73cd (diff)
downloadchromium_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 'net/disk_cache')
-rw-r--r--net/disk_cache/blockfile/backend_impl.cc9
-rw-r--r--net/disk_cache/blockfile/backend_impl_v3.cc9
-rw-r--r--net/disk_cache/entry_unittest.cc7
3 files changed, 13 insertions, 12 deletions
diff --git a/net/disk_cache/blockfile/backend_impl.cc b/net/disk_cache/blockfile/backend_impl.cc
index 5133ea5..78bfa42 100644
--- a/net/disk_cache/blockfile/backend_impl.cc
+++ b/net/disk_cache/blockfile/backend_impl.cc
@@ -15,6 +15,7 @@
#include "base/metrics/histogram.h"
#include "base/rand_util.h"
#include "base/single_thread_task_runner.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
@@ -1289,19 +1290,19 @@ void BackendImpl::GetStats(StatsItems* stats) {
std::pair<std::string, std::string> item;
item.first = "Entries";
- item.second = base::StringPrintf("%d", data_->header.num_entries);
+ item.second = base::IntToString(data_->header.num_entries);
stats->push_back(item);
item.first = "Pending IO";
- item.second = base::StringPrintf("%d", num_pending_io_);
+ item.second = base::IntToString(num_pending_io_);
stats->push_back(item);
item.first = "Max size";
- item.second = base::StringPrintf("%d", max_size_);
+ item.second = base::IntToString(max_size_);
stats->push_back(item);
item.first = "Current size";
- item.second = base::StringPrintf("%d", data_->header.num_bytes);
+ item.second = base::IntToString(data_->header.num_bytes);
stats->push_back(item);
item.first = "Cache type";
diff --git a/net/disk_cache/blockfile/backend_impl_v3.cc b/net/disk_cache/blockfile/backend_impl_v3.cc
index 56804bc..36402510 100644
--- a/net/disk_cache/blockfile/backend_impl_v3.cc
+++ b/net/disk_cache/blockfile/backend_impl_v3.cc
@@ -12,6 +12,7 @@
#include "base/message_loop/message_loop.h"
#include "base/metrics/field_trial.h"
#include "base/rand_util.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/sys_info.h"
@@ -690,19 +691,19 @@ void BackendImplV3::GetStats(StatsItems* stats) {
std::pair<std::string, std::string> item;
item.first = "Entries";
- item.second = base::StringPrintf("%d", data_->header.num_entries);
+ item.second = base::IntToString(data_->header.num_entries);
stats->push_back(item);
item.first = "Pending IO";
- item.second = base::StringPrintf("%d", num_pending_io_);
+ item.second = base::IntToString(num_pending_io_);
stats->push_back(item);
item.first = "Max size";
- item.second = base::StringPrintf("%d", max_size_);
+ item.second = base::IntToString(max_size_);
stats->push_back(item);
item.first = "Current size";
- item.second = base::StringPrintf("%d", data_->header.num_bytes);
+ item.second = base::IntToString(data_->header.num_bytes);
stats->push_back(item);
item.first = "Cache type";
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc
index f16cbda..c7b3ff1 100644
--- a/net/disk_cache/entry_unittest.cc
+++ b/net/disk_cache/entry_unittest.cc
@@ -7,8 +7,8 @@
#include "base/bind_helpers.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
+#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
-#include "base/strings/stringprintf.h"
#include "base/threading/platform_thread.h"
#include "net/base/completion_callback.h"
#include "net/base/io_buffer.h"
@@ -3380,7 +3380,7 @@ TEST_F(DiskCacheEntryTest, SimpleCacheEvictOldEntries) {
// will be checked for outliving the eviction.
AddDelay();
}
- ASSERT_EQ(net::OK, CreateEntry(key2 + base::StringPrintf("%d", i), &entry));
+ ASSERT_EQ(net::OK, CreateEntry(key2 + base::IntToString(i), &entry));
ScopedEntryPtr entry_closer(entry);
EXPECT_EQ(kWriteSize,
WriteData(entry, 1, 0, buffer.get(), kWriteSize, false));
@@ -3395,8 +3395,7 @@ TEST_F(DiskCacheEntryTest, SimpleCacheEvictOldEntries) {
// Generally there is no guarantee that at this point the backround eviction
// is finished. We are testing the positive case, i.e. when the eviction
// never reaches this entry, should be non-flaky.
- ASSERT_EQ(net::OK, OpenEntry(key2 + base::StringPrintf("%d", entry_no),
- &entry))
+ ASSERT_EQ(net::OK, OpenEntry(key2 + base::IntToString(entry_no), &entry))
<< "Should not have evicted fresh entry " << entry_no;
entry->Close();
}