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

Unified Diff: pkg/analyzer/lib/src/context/cache.dart

Issue 1120313004: Get memento objects from tasks, remember in cache and pass back to tasks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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 | pkg/analyzer/lib/src/task/driver.dart » ('j') | pkg/analyzer/lib/src/task/driver.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/context/cache.dart
diff --git a/pkg/analyzer/lib/src/context/cache.dart b/pkg/analyzer/lib/src/context/cache.dart
index 4ef2814a792dabf89efce162db140f8391556782..5d8354f6b41b58f4dccbc97580e48eeb6003697a 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -331,6 +331,17 @@ class CacheEntry {
}
/**
+ * Return the memento of the result represented by the given [descriptor].
+ */
+ dynamic getMemento(ResultDescriptor descriptor) {
+ ResultData data = _resultMap[descriptor];
+ if (data == null) {
+ return null;
+ }
+ return data.memento;
+ }
+
+ /**
* Return the state of the result represented by the given [descriptor].
*/
CacheState getState(ResultDescriptor descriptor) {
@@ -441,10 +452,11 @@ class CacheEntry {
/**
* Set the value of the result represented by the given [descriptor] to the
- * given [value].
+ * given [value]. The optional [memento] may help to recompute [value] more
+ * efficiently after invalidation.
*/
/*<V>*/ void setValue(ResultDescriptor /*<V>*/ descriptor, dynamic /*V*/
- value, List<TargetedResult> dependedOn) {
+ value, List<TargetedResult> dependedOn, [dynamic memento]) {
_validateStateChange(descriptor, CacheState.VALID);
ResultData data = _getResultData(descriptor);
{
@@ -454,6 +466,7 @@ class CacheEntry {
}
data.state = CacheState.VALID;
data.value = value == null ? descriptor.defaultValue : value;
+ data.memento = memento;
}
@override
@@ -821,6 +834,12 @@ class ResultData {
Object value;
/**
+ * The optional data that is remembered with [value] and, when [value] is
+ * invalidated, may help to recompute it more efficiently.
+ */
+ dynamic memento;
Brian Wilkerson 2015/05/04 16:22:09 nit: I generally prefer 'Object' over 'dynamic' as
+
+ /**
* A list of the results on which this result depends.
*/
List<TargetedResult> dependedOnResults = <TargetedResult>[];
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/task/driver.dart » ('j') | pkg/analyzer/lib/src/task/driver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698