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

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

Issue 1133863006: Don't invalidate dependent results when set values. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 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 | « no previous file | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »
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 fa7bf4834b2a31ac74d3bf7dd43fd0a300a6faee..5ce68482174f20d5da9d9467b52009f5a595edc4 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -372,7 +372,7 @@ class CacheEntry {
if (state == CacheState.INVALID) {
ResultData data = _resultMap[descriptor];
if (data != null) {
- _invalidate(descriptor, true);
+ _invalidate(descriptor);
}
} else {
ResultData data = _getResultData(descriptor);
@@ -398,7 +398,6 @@ class CacheEntry {
if (_partition != null) {
_partition.resultStored(thisResult, value);
}
- _invalidate(descriptor, false);
ResultData data = _getResultData(descriptor);
_setDependedOnResults(data, thisResult, dependedOn);
data.state = CacheState.VALID;
@@ -426,17 +425,11 @@ class CacheEntry {
}
/**
- * Invalidate the result represented by the given [descriptor] if
- * [includeThis] is true. Propagate invalidation to other results that
- * depend on it.
+ * Invalidate the result represented by the given [descriptor] and propagate
+ * invalidation to other results that depend on it.
*/
- void _invalidate(ResultDescriptor descriptor, bool includeThis) {
- ResultData thisData;
- if (includeThis) {
- thisData = _resultMap.remove(descriptor);
- } else {
- thisData = _resultMap[descriptor];
- }
+ void _invalidate(ResultDescriptor descriptor) {
+ ResultData thisData = _resultMap.remove(descriptor);
if (thisData == null) {
return;
}
@@ -454,7 +447,7 @@ class CacheEntry {
dependentResults.forEach((TargetedResult dependentResult) {
CacheEntry entry = _partition.get(dependentResult.target);
if (entry != null) {
- entry._invalidate(dependentResult.result, true);
+ entry._invalidate(dependentResult.result);
}
});
// If empty, remove the entry altogether.
@@ -469,7 +462,7 @@ class CacheEntry {
void _invalidateAll() {
List<ResultDescriptor> results = _resultMap.keys.toList();
for (ResultDescriptor result in results) {
- _invalidate(result, true);
+ _invalidate(result);
}
}
@@ -478,10 +471,18 @@ class CacheEntry {
*/
void _setDependedOnResults(ResultData thisData, TargetedResult thisResult,
List<TargetedResult> dependedOn) {
+ thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) {
+ ResultData data = _partition._getDataFor(dependedOnResult, orNull: true);
+ if (data != null) {
+ data.dependentResults.remove(thisResult);
+ }
+ });
thisData.dependedOnResults = dependedOn;
- thisData.dependedOnResults.forEach((TargetedResult dependentResult) {
- ResultData data = _partition._getDataFor(dependentResult);
- data.dependentResults.add(thisResult);
+ thisData.dependedOnResults.forEach((TargetedResult dependedOnResult) {
+ ResultData data = _partition._getDataFor(dependedOnResult, orNull: true);
+ if (data != null) {
+ data.dependentResults.add(thisResult);
+ }
});
}
« no previous file with comments | « no previous file | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698