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

Unified Diff: runtime/vm/fixed_cache.h

Issue 2734323003: Re-landing of "replace TrySync with Metadata". (Closed)
Patch Set: Address review comments Created 3 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 | « runtime/vm/exceptions.cc ('k') | runtime/vm/fixed_cache_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/fixed_cache.h
diff --git a/runtime/vm/fixed_cache.h b/runtime/vm/fixed_cache.h
index eac919dc844c984f17fac9e4e744fc5c5c3c7df1..2d6e00a7507b60fa915f4c78c370a5addbe6df37 100644
--- a/runtime/vm/fixed_cache.h
+++ b/runtime/vm/fixed_cache.h
@@ -12,25 +12,21 @@ namespace dart {
// A simple sorted fixed size Key-Value storage.
//
-// Assumes both Key and Value are POD-like objects.
+// Assumes both Key and Value are default-constructible objects.
//
// Keys must be comparable with operator<.
//
// Duplicates are not allowed - check with Lookup before insertion.
//
-// Optionally Values may have cleanup function to delete
-// any resources they point to.
template <class K, class V, intptr_t kCapacity>
class FixedCache {
public:
- typedef void (*Deleter)(V*);
-
struct Entry {
K key;
V value;
};
- explicit FixedCache(Deleter deleter = NULL) : deleter_(deleter), length_(0) {}
+ FixedCache() : length_(0) {}
~FixedCache() { Clear(); }
@@ -44,7 +40,6 @@ class FixedCache {
intptr_t i = LowerBound(key);
if (length_ == kCapacity) {
- if (deleter_) deleter_(&pairs_[length_ - 1].value);
length_ = kCapacity - 1;
if (i == kCapacity) i = kCapacity - 1;
}
@@ -59,11 +54,6 @@ class FixedCache {
}
void Clear() {
- if (deleter_) {
- for (intptr_t i = 0; i < length_; i++) {
- deleter_(&pairs_[i].value);
- }
- }
length_ = 0;
}
@@ -84,7 +74,6 @@ class FixedCache {
}
Entry pairs_[kCapacity]; // Sorted array of pairs.
- Deleter deleter_;
intptr_t length_;
};
« no previous file with comments | « runtime/vm/exceptions.cc ('k') | runtime/vm/fixed_cache_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698