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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/ContextCodec.java

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
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/SplitIndexStoreImpl.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/ContextCodec.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/ContextCodec.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/ContextCodec.java
index 06336cfff9daf7eef34986b451709b3cd3bc6133..d082c65a7b03e859083e940940e2abc51874883b 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/ContextCodec.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/ContextCodec.java
@@ -13,7 +13,7 @@
*/
package com.google.dart.engine.internal.index.file;
-import com.google.common.collect.MapMaker;
+import com.google.common.collect.Maps;
import com.google.dart.engine.context.AnalysisContext;
import java.util.Map;
@@ -27,12 +27,17 @@ public class ContextCodec {
/**
* A table mapping contexts to their unique indices.
*/
- private final Map<AnalysisContext, Integer> contextToIndex = new MapMaker().weakKeys().makeMap();
+ private final Map<AnalysisContext, Integer> contextToIndex = Maps.newHashMap();
/**
* A table mapping indices to the corresponding contexts.
*/
- private final Map<Integer, AnalysisContext> indexToContext = new MapMaker().weakValues().makeMap();
+ private final Map<Integer, AnalysisContext> indexToContext = Maps.newHashMap();
+
+ /**
+ * The next id to assign.
+ */
+ private int nextId;
/**
* Returns the {@link AnalysisContext} that corresponds to the given index.
@@ -47,10 +52,20 @@ public class ContextCodec {
public int encode(AnalysisContext context) {
Integer index = contextToIndex.get(context);
if (index == null) {
- index = indexToContext.size();
+ index = nextId++;
contextToIndex.put(context, index);
indexToContext.put(index, context);
}
return index;
}
+
+ /**
+ * Removes the given {@link AnalysisContext}.
+ */
+ public void removeContext(AnalysisContext context) {
+ Integer id = contextToIndex.remove(context);
+ if (id != null) {
+ indexToContext.remove(id);
+ }
+ }
}
« no previous file with comments | « no previous file | editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/index/file/SplitIndexStoreImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698