Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: net/disk_cache/simple/simple_util.cc

Issue 1977863003: SimpleCache: open with fewer seeks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@open-speeder-macbetter
Patch Set: actually fix test Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/disk_cache/simple/simple_util.h ('k') | net/disk_cache/simple/simple_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_util.cc
diff --git a/net/disk_cache/simple/simple_util.cc b/net/disk_cache/simple/simple_util.cc
index a81c28ff4f6ca240ae76d548d7863171e501e8ec..eac565bc7b6a3a09bd99e634c904b4b68bc2b240 100644
--- a/net/disk_cache/simple/simple_util.cc
+++ b/net/disk_cache/simple/simple_util.cc
@@ -97,17 +97,19 @@ std::string GetFilenameFromKeyAndFileIndex(const std::string& key,
base::StringPrintf("_%1d", file_index);
}
-int32_t GetDataSizeFromKeyAndFileSize(const std::string& key,
- int64_t file_size) {
+size_t GetHeaderSize(size_t key_length) {
+ return sizeof(SimpleFileHeader) + key_length;
+}
+
+int32_t GetDataSizeFromFileSize(size_t key_length, int64_t file_size) {
int64_t data_size =
- file_size - key.size() - sizeof(SimpleFileHeader) - sizeof(SimpleFileEOF);
+ file_size - key_length - sizeof(SimpleFileHeader) - sizeof(SimpleFileEOF);
return base::checked_cast<int32_t>(data_size);
}
-int64_t GetFileSizeFromKeyAndDataSize(const std::string& key,
- int32_t data_size) {
- return data_size + key.size() + sizeof(SimpleFileHeader) +
- sizeof(SimpleFileEOF);
+int64_t GetFileSizeFromDataSize(size_t key_length, int32_t data_size) {
+ return data_size + key_length + sizeof(SimpleFileHeader) +
+ sizeof(SimpleFileEOF);
}
int GetFileIndexFromStreamIndex(int stream_index) {
« no previous file with comments | « net/disk_cache/simple/simple_util.h ('k') | net/disk_cache/simple/simple_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698