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

Unified Diff: base/containers/mru_cache.h

Issue 983223004: base: Remove non-const refs from the MRUCache implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « no previous file | chrome/browser/ui/app_list/search/common/webservice_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/mru_cache.h
diff --git a/base/containers/mru_cache.h b/base/containers/mru_cache.h
index 15ea2fccdc4104dfbae4961cc24674c475230771..30974514244d2ed29bbfa47e9f398107d1b7dfb4 100644
--- a/base/containers/mru_cache.h
+++ b/base/containers/mru_cache.h
@@ -140,7 +140,7 @@ class MRUCacheBase {
// Erases the item referenced by the given iterator. An iterator to the item
// following it will be returned. The iterator must be valid.
iterator Erase(iterator pos) {
- deletor_(pos->second);
+ deletor_(&pos->second);
index_.erase(pos->first);
return ordering_.erase(pos);
}
@@ -165,7 +165,7 @@ class MRUCacheBase {
void Clear() {
for (typename PayloadList::iterator i(ordering_.begin());
i != ordering_.end(); ++i)
- deletor_(i->second);
+ deletor_(&i->second);
index_.clear();
ordering_.clear();
}
@@ -213,8 +213,7 @@ class MRUCacheBase {
template<class PayloadType>
class MRUCacheNullDeletor {
public:
- void operator()(PayloadType& payload) {
- }
+ void operator()(PayloadType* payload) {}
};
// A container that does not do anything to free its data. Use this when storing
@@ -244,9 +243,7 @@ class MRUCache : public MRUCacheBase<KeyType,
template<class PayloadType>
class MRUCachePointerDeletor {
public:
- void operator()(PayloadType& payload) {
- delete payload;
- }
+ void operator()(PayloadType* payload) { delete *payload; }
Nico 2015/03/07 01:06:14 can't you just make this const PalyloadType& ? I t
};
// A cache that owns the payload type, which must be a non-const pointer type.
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/search/common/webservice_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698