diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java index e2a65a01ab02..311a854585de 100644 --- a/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java +++ b/platform/platform-impl/src/com/intellij/openapi/vfs/impl/local/FileWatcher.java @@ -67,6 +67,12 @@ public class FileWatcher { public final List dirtyPaths = newArrayList(); public final List dirtyPathsRecursive = newArrayList(); public final List dirtyDirectories = newArrayList(); + + private static DirtyPaths EMPTY = new DirtyPaths(); + + private boolean isEmpty() { + return dirtyPaths.isEmpty() && dirtyPathsRecursive.isEmpty() && dirtyDirectories.isEmpty(); + } } private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vfs.impl.local.FileWatcher"); @@ -148,11 +154,16 @@ public class FileWatcher { @NotNull public DirtyPaths getDirtyPaths() { synchronized (myLock) { - DirtyPaths dirtyPaths = myDirtyPaths; - myDirtyPaths = new DirtyPaths(); - myLastChangedPathIndex = 0; - for(int i = 0; i < myLastChangedPaths.length; ++i) myLastChangedPaths[i] = null; - return dirtyPaths; + if (!myDirtyPaths.isEmpty()) { + DirtyPaths dirtyPaths = myDirtyPaths; + myDirtyPaths = new DirtyPaths(); + myLastChangedPathIndex = 0; + for (int i = 0; i < myLastChangedPaths.length; ++i) myLastChangedPaths[i] = null; + return dirtyPaths; + } + else { + return DirtyPaths.EMPTY; + } } }