- filter out invalid index ids earlier
authorMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Tue, 3 May 2016 19:55:42 +0000 (21:55 +0200)
committerMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Tue, 3 May 2016 19:55:42 +0000 (21:55 +0200)
- set dirty flag if there is a change in stamps

platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexImpl.java
platform/lang-impl/src/com/intellij/util/indexing/IndexingStamp.java

index 284c297ff83bef3560656ebf202da0bf004120bc..8c3250b6e3c2b1178228b129ee55c95d5f347d70 100644 (file)
@@ -537,24 +537,13 @@ public class FileBasedIndexImpl extends FileBasedIndex {
   }
 
   private void removeDataFromIndicesForFile(final int fileId) {
-    // All (indices) IDs should be valid in this running session (e.g. we can have ID instance existing but index is not registered)
-    final List<ID<?, ?>> currentFileIndexedStates = IndexingStamp.getNontrivialFileIndexedStates(fileId);
-    Collection<ID<?, ?>> states = currentFileIndexedStates;
-    IndexConfiguration state = getState();
-
-    for(ID<?,?> currentFileIndexedState: currentFileIndexedStates) {
-      if (!state.hasIndex(currentFileIndexedState)) {
-        states = ContainerUtil.intersection(currentFileIndexedStates, state.getIndexIDs());
-        break;
-      }
-    }
+    final List<ID<?, ?>> states = IndexingStamp.getNontrivialFileIndexedStates(fileId);
 
     if (!states.isEmpty()) {
-      final Collection<ID<?, ?>> finalStates = states;
       ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
         @Override
         public void run() {
-          removeFileDataFromIndices(finalStates, fileId);
+          removeFileDataFromIndices(states, fileId);
         }
       });
     }
index 9e50c83fc7b333f25ccbb3f7d00dd131ae34eba3..c91e0e80f1f6a7e65bc3c000af331c246ba19926 100644 (file)
@@ -206,6 +206,7 @@ public class IndexingStamp {
             ID<?, ?> id = ID.findById(DataInputOutputUtil.readINT(stream));
             if (id != null) {
               long stamp = getIndexCreationStamp(id);
+              if (stamp == 0) continue; // All (indices) IDs should be valid in this running session (e.g. we can have ID instance existing but index is not registered)
               if (myIndexStamps == null) myIndexStamps = new TObjectLongHashMap<ID<?, ?>>(5, 0.98f);
               if (stamp <= dominatingIndexStamp) myIndexStamps.put(id, stamp);
             }
@@ -294,14 +295,10 @@ public class IndexingStamp {
     }
 
     private void set(ID<?, ?> id, long tmst) {
-      try {
-        if (myIndexStamps == null) myIndexStamps = new TObjectLongHashMap<ID<?, ?>>(5, 0.98f);
+      if (myIndexStamps == null) myIndexStamps = new TObjectLongHashMap<ID<?, ?>>(5, 0.98f);
 
-        myIndexStamps.put(id, tmst);
-      }
-      finally {
-        myIsDirty = true;
-      }
+      long previous = myIndexStamps.put(id, tmst);
+      if (previous != tmst) myIsDirty = true;
     }
 
     public boolean isDirty() {