From 80a4d348a8df9418c835b7a857f68312b5783fce Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 9 Jun 2018 10:38:12 +0300 Subject: [PATCH] vcs: don't scan for vcs roots of content roots, which are under project dir If a content root is located inside the project base dir, its roots will already be scanned. On the other hand, if there are a lot of modules, scanning each of it produces a lot of extra work. Relates to IDEA-174636 --- .../intellij/openapi/vcs/roots/VcsRootDetectorImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/roots/VcsRootDetectorImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/roots/VcsRootDetectorImpl.java index 866c503d207c..f6021a6a551a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/roots/VcsRootDetectorImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/roots/VcsRootDetectorImpl.java @@ -26,6 +26,7 @@ import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.VcsRoot; import com.intellij.openapi.vcs.VcsRootChecker; import com.intellij.openapi.vfs.VfsUtil; +import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; @@ -78,8 +79,10 @@ public class VcsRootDetectorImpl implements VcsRootDetector { Set vcsRoots = new HashSet<>(); if (myProject.isDisposed()) return vcsRoots; - VirtualFile[] roots = myProjectManager.getContentRoots(); - for (VirtualFile contentRoot : roots) { + for (VirtualFile contentRoot : myProjectManager.getContentRoots()) { + if (myProject.getBaseDir() != null && VfsUtilCore.isAncestor(myProject.getBaseDir(), contentRoot, false)) { + continue; + } Set rootsInsideRoot = scanForRootsInsideDir(contentRoot); boolean shouldScanAbove = true;