foolproof null directory info caching

This commit is contained in:
peter
2013-11-04 18:27:36 +01:00
parent e9bd45eff0
commit 75a447a835
2 changed files with 4 additions and 4 deletions
@@ -41,6 +41,7 @@ import java.util.*;
class RootIndex {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.RootIndex");
private static final DirectoryInfo NULL_INFO = DirectoryInfo.createNew();
private final Set<VirtualFile> myProjectExcludedRoots = ContainerUtil.newHashSet();
private final Set<VirtualFile> myLibraryExcludedRoots = ContainerUtil.newHashSet();
@@ -322,7 +323,7 @@ class RootIndex {
}
DirectoryInfo info = myInfoCache.get(root);
if (info != null) {
return info == DirectoryInfo.EMPTY ? null : info;
return info == NULL_INFO ? null : info;
}
info = myRoots.get(root);
@@ -332,12 +333,12 @@ class RootIndex {
}
if (isAnyExcludeRoot(root) || FileTypeManager.getInstance().isFileIgnored(root)) {
myInfoCache.put(dir, DirectoryInfo.EMPTY);
myInfoCache.put(dir, NULL_INFO);
return null;
}
}
myInfoCache.put(dir, DirectoryInfo.EMPTY);
myInfoCache.put(dir, NULL_INFO);
return null;
}
@@ -36,7 +36,6 @@ import java.util.Comparator;
import java.util.List;
public final class DirectoryInfo {
static final DirectoryInfo EMPTY = createNew();
public static final int MAX_ROOT_TYPE_ID = (1 << (Byte.SIZE - 2)) - 1;
private final Module module; // module to which content it belongs or null
private final VirtualFile libraryClassRoot; // class root in library