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

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

Issue 1130263002: Some clean ups for cache partitions. (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 343dd5258772e046b30dade4804143b8c2e9543c..a7a67104a5128fb6b88e01718f505fa707ea16f1 100644
--- a/pkg/analyzer/lib/src/context/cache.dart
+++ b/pkg/analyzer/lib/src/context/cache.dart
@@ -65,8 +65,9 @@ class AnalysisCache {
CacheEntry get(AnalysisTarget target) {
int count = _partitions.length;
for (int i = 0; i < count; i++) {
- if (_partitions[i].contains(target)) {
- return _partitions[i].get(target);
+ CachePartition partition = _partitions[i];
+ if (partition.isResponsibleFor(target)) {
+ return partition.get(target);
}
}
//
@@ -83,8 +84,9 @@ class AnalysisCache {
InternalAnalysisContext getContextFor(AnalysisTarget target) {
int count = _partitions.length;
for (int i = 0; i < count; i++) {
- if (_partitions[i].contains(target)) {
- return _partitions[i].context;
+ CachePartition partition = _partitions[i];
+ if (partition.isResponsibleFor(target)) {
+ return partition.context;
}
}
//
@@ -119,9 +121,10 @@ class AnalysisCache {
entry.fixExceptionState();
int count = _partitions.length;
for (int i = 0; i < count; i++) {
- if (_partitions[i].contains(target)) {
+ CachePartition partition = _partitions[i];
+ if (partition.isResponsibleFor(target)) {
if (_TRACE_CHANGES) {
- CacheEntry oldEntry = _partitions[i].get(target);
+ CacheEntry oldEntry = partition.get(target);
if (oldEntry == null) {
AnalysisEngine.instance.logger
.logInformation('Added a cache entry for $target.');
@@ -131,7 +134,7 @@ class AnalysisCache {
// 'Diff = ${entry.getDiff(oldEntry)}');
}
}
- _partitions[i].put(target, entry);
+ partition.put(target, entry);
return;
}
}
@@ -145,12 +148,13 @@ class AnalysisCache {
void remove(AnalysisTarget target) {
int count = _partitions.length;
for (int i = 0; i < count; i++) {
- if (_partitions[i].contains(target)) {
+ CachePartition partition = _partitions[i];
+ if (partition.isResponsibleFor(target)) {
if (_TRACE_CHANGES) {
AnalysisEngine.instance.logger
.logInformation('Removed the cache entry for $target.');
}
- _partitions[i].remove(target);
+ partition.remove(target);
return;
}
}
@@ -169,13 +173,9 @@ class AnalysisCache {
}
ResultData _getDataFor(TargetedResult result) {
- AnalysisTarget target = result.target;
- int count = _partitions.length;
- for (int i = 0; i < count; i++) {
- if (_partitions[i].contains(target)) {
- CacheEntry entry = _partitions[i].get(target);
- return entry._getResultData(result.result);
- }
+ CacheEntry entry = get(result.target);
+ if (entry != null) {
+ return entry._getResultData(result.result);
}
return null;
}
@@ -675,11 +675,9 @@ abstract class CachePartition {
Map<AnalysisTarget, CacheEntry> get map => _targetMap;
/**
- * Return `true` if the given [target] is contained in this partition.
+ * Return `true` if this partition is responsible for the given [target].
*/
- // TODO(brianwilkerson) Rename this to something more meaningful, such as
- // isResponsibleFor.
- bool contains(AnalysisTarget target);
+ bool isResponsibleFor(AnalysisTarget target);
Brian Wilkerson 2015/05/07 20:03:07 Thanks!
/**
* Return the entry associated with the given [target].
@@ -831,7 +829,7 @@ class SdkCachePartition extends CachePartition {
SdkCachePartition(InternalAnalysisContext context) : super(context);
@override
- bool contains(AnalysisTarget target) {
+ bool isResponsibleFor(AnalysisTarget target) {
if (target is AnalysisContextTarget) {
return true;
}
@@ -891,5 +889,5 @@ class UniversalCachePartition extends CachePartition {
UniversalCachePartition(InternalAnalysisContext context) : super(context);
@override
- bool contains(AnalysisTarget target) => true;
+ bool isResponsibleFor(AnalysisTarget target) => true;
}
« 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