optimize removing invalid files
authorSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 27 May 2016 18:54:10 +0000 (21:54 +0300)
committerSergey Simonchik <sergey.simonchik@jetbrains.com>
Fri, 27 May 2016 18:54:10 +0000 (21:54 +0300)
platform/projectModel-api/src/com/intellij/lang/PerFileMappingsBase.java

index f7b45ddacb06048c95601d66059114ba672f5690..bb6b9d9bb1aea7d1e5d0b3067fd7c9fda2a8f1b2 100644 (file)
@@ -60,10 +60,10 @@ public abstract class PerFileMappingsBase<T> implements PersistentStateComponent
   }
 
   private void cleanup() {
-    for (final VirtualFile file : new ArrayList<VirtualFile>(myMappings.keySet())) {
-      if (file != null //PROJECT, top-level
-          && !file.isValid()) {
-        myMappings.remove(file);
+    for (Iterator<VirtualFile> i = myMappings.keySet().iterator(); i.hasNext();) {
+      VirtualFile file = i.next();
+      if (file != null /* PROJECT, top-level */ && !file.isValid()) {
+        i.remove();
       }
     }
   }