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

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

Issue 2267273004: Use FlushTargetFilter to pre-filter targets before checking their results. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 4 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
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 6669d04f1df6adc7636679a7be9b66d00a6f0d52..104d89a55cc4a91b627b141cf6e63e45cb7084c0 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -27,6 +27,11 @@ typedef bool FlushResultFilter<V>(
AnalysisTarget target, ResultDescriptor<V> result);
/**
+ * Return `true` if some results of the [target] should be flushed.
+ */
+typedef bool FlushTargetFilter<V>(AnalysisTarget target);
+
+/**
* Return `true` if the given [target] is a priority one.
*/
typedef bool IsPriorityAnalysisTarget(AnalysisTarget target);
@@ -113,11 +118,11 @@ class AnalysisCache {
}
/**
- * Flush results that satisfy the given [filter].
+ * Flush results that satisfy the given [targetFilter] and [resultFilter].
*/
- void flush(FlushResultFilter filter) {
+ void flush(FlushTargetFilter targetFilter, FlushResultFilter resultFilter) {
for (CachePartition partition in _partitions) {
- partition.flush(filter);
+ partition.flush(targetFilter, resultFilter);
}
}
@@ -405,16 +410,18 @@ class CacheEntry {
}
/**
- * Flush results that satisfy the given [filter].
+ * Flush results that satisfy the given [targetFilter] and [resultFilter].
*/
- void flush(FlushResultFilter filter) {
- _resultMap.forEach((ResultDescriptor result, ResultData data) {
- if (data.state == CacheState.VALID) {
- if (filter(target, result)) {
- data.flush();
+ void flush(FlushTargetFilter targetFilter, FlushResultFilter resultFilter) {
+ if (targetFilter(target)) {
+ _resultMap.forEach((ResultDescriptor result, ResultData data) {
+ if (data.state == CacheState.VALID) {
+ if (resultFilter(target, result)) {
+ data.flush();
+ }
}
- }
- });
+ });
+ }
}
/**
@@ -1092,11 +1099,11 @@ abstract class CachePartition {
}
/**
- * Flush results that satisfy the given [filter].
+ * Flush results that satisfy the given [targetFilter] and [resultFilter].
*/
- void flush(FlushResultFilter filter) {
+ void flush(FlushTargetFilter targetFilter, FlushResultFilter resultFilter) {
for (CacheEntry entry in entryMap.values) {
- entry.flush(filter);
+ entry.flush(targetFilter, resultFilter);
}
}
« no previous file with comments | « pkg/analysis_server/lib/src/operation/operation_analysis.dart ('k') | pkg/analyzer/test/src/context/cache_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698