Commit 9e6f8526 authored by rvargas@google.com's avatar rvargas@google.com

Disk cache: Additional code cleanup after CL 20067.

BUG=15596
TEST=none

Review URL: http://codereview.chromium.org/155231

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20190 0039d316-1c4b-4281-b951-d872f2087c98
parent f01b25cd
...@@ -1103,8 +1103,8 @@ int BackendImpl::NewEntry(Addr address, EntryImpl** entry, bool* dirty) { ...@@ -1103,8 +1103,8 @@ int BackendImpl::NewEntry(Addr address, EntryImpl** entry, bool* dirty) {
EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash,
bool find_parent) { bool find_parent) {
Addr address(data_->table[hash & mask_]); Addr address(data_->table[hash & mask_]);
EntryImpl* cache_entry = NULL; scoped_refptr<EntryImpl> cache_entry, parent_entry;
EntryImpl* parent_entry = NULL; EntryImpl* tmp = NULL;
bool found = false; bool found = false;
for (;;) { for (;;) {
...@@ -1118,7 +1118,8 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, ...@@ -1118,7 +1118,8 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash,
} }
bool dirty; bool dirty;
int error = NewEntry(address, &cache_entry, &dirty); int error = NewEntry(address, &tmp, &dirty);
cache_entry.swap(&tmp);
if (error || dirty) { if (error || dirty) {
// This entry is dirty on disk (it was not properly closed): we cannot // This entry is dirty on disk (it was not properly closed): we cannot
...@@ -1129,7 +1130,6 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, ...@@ -1129,7 +1130,6 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash,
if (parent_entry) { if (parent_entry) {
parent_entry->SetNextAddress(child); parent_entry->SetNextAddress(child);
parent_entry->Release();
parent_entry = NULL; parent_entry = NULL;
} else { } else {
data_->table[hash & mask_] = child.value(); data_->table[hash & mask_] = child.value();
...@@ -1139,7 +1139,6 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, ...@@ -1139,7 +1139,6 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash,
// It is important to call DestroyInvalidEntry after removing this // It is important to call DestroyInvalidEntry after removing this
// entry from the table. // entry from the table.
DestroyInvalidEntry(address, cache_entry); DestroyInvalidEntry(address, cache_entry);
cache_entry->Release();
cache_entry = NULL; cache_entry = NULL;
} else { } else {
Trace("NewEntry failed on MatchEntry 0x%x", address.value()); Trace("NewEntry failed on MatchEntry 0x%x", address.value());
...@@ -1151,19 +1150,13 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, ...@@ -1151,19 +1150,13 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash,
} }
if (cache_entry->IsSameEntry(key, hash)) { if (cache_entry->IsSameEntry(key, hash)) {
if (!cache_entry->Update()) { if (!cache_entry->Update())
cache_entry->Release();
cache_entry = NULL; cache_entry = NULL;
}
found = true; found = true;
break; break;
} }
if (!cache_entry->Update()) { if (!cache_entry->Update())
cache_entry->Release();
cache_entry = NULL; cache_entry = NULL;
}
if (parent_entry)
parent_entry->Release();
parent_entry = cache_entry; parent_entry = cache_entry;
cache_entry = NULL; cache_entry = NULL;
if (!parent_entry) if (!parent_entry)
...@@ -1172,17 +1165,14 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash, ...@@ -1172,17 +1165,14 @@ EntryImpl* BackendImpl::MatchEntry(const std::string& key, uint32 hash,
address.set_value(parent_entry->GetNextAddress()); address.set_value(parent_entry->GetNextAddress());
} }
if (parent_entry && (!find_parent || !found)) { if (parent_entry && (!find_parent || !found))
parent_entry->Release();
parent_entry = NULL; parent_entry = NULL;
}
if (cache_entry && (find_parent || !found)) { if (cache_entry && (find_parent || !found))
cache_entry->Release();
cache_entry = NULL; cache_entry = NULL;
}
return find_parent ? parent_entry : cache_entry; find_parent ? parent_entry.swap(&tmp) : cache_entry.swap(&tmp);
return tmp;
} }
// This is the actual implementation for OpenNextEntry and OpenPrevEntry. // This is the actual implementation for OpenNextEntry and OpenPrevEntry.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment