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

Unified Diff: pkg/analysis_server/lib/src/index/split_store.dart

Issue 347133002: Explicitly remove AnalysisContext from ContextCodec. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix for IDs generation Created 6 years, 6 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/analysis_server/lib/src/index/split_store.dart
diff --git a/pkg/analysis_server/lib/src/index/split_store.dart b/pkg/analysis_server/lib/src/index/split_store.dart
index 8c31ca914dcb2aa5194388284b7a363f6cf34d8c..b50f6b2d9a24f5793835f365cd447a110622f3fe 100644
--- a/pkg/analysis_server/lib/src/index/split_store.dart
+++ b/pkg/analysis_server/lib/src/index/split_store.dart
@@ -35,6 +35,11 @@ class ContextCodec {
);
/**
+ * The next id to assign.
+ */
+ int _nextId = 0;
+
+ /**
* Returns the [AnalysisContext] that corresponds to the given index.
*/
AnalysisContext decode(int index) => _indexToContext[index];
@@ -45,12 +50,22 @@ class ContextCodec {
int encode(AnalysisContext context) {
int index = _contextToIndex[context];
if (index == null) {
- index = _indexToContext.length;
+ index = _nextId++;
_contextToIndex[context] = index;
_indexToContext[index] = context;
}
return index;
}
+
+ /**
+ * Removes the given [context].
+ */
+ void remove(AnalysisContext context) {
+ int id = _contextToIndex.remove(context);
+ if (id != null) {
+ _indexToContext.remove(id);
+ }
+ }
}
@@ -904,6 +919,8 @@ class SplitIndexStore implements IndexStore {
_contextToLibraryToUnits.remove(context);
_contextToUnitToLibraries.remove(context);
_contextNodeRelations.remove(_contextCodec.encode(context));
+ // remove context from codec
+ _contextCodec.remove(context);
}
@override

Powered by Google App Engine
This is Rietveld 408576698