1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 13:25:45 +02:00

Bug 565553 - Improve performance of build command parsers with large number of files

Optimize AbstractLanguageSettingsOutputScanner.findResource by checking
under the currentProject first when searching for the IFile
corresponding to the parsed file name.

When the parsed file name is absolute, we can try to make it relative to
the current project and see if it exists as an IFile instead of going
through findFilesForLocationURI which is very slow. Having an absolute
path for the source file is quite common under the current (local)
projet.

This saves around 1.5 sec when parsing all commands of LLVM projet as an
example.

Change-Id: I576a917410e5d5ecbd8e932011555c699b250354
Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
Marc-Andre Laperle 2020-09-05 22:25:34 -04:00 committed by Marc-André Laperle
parent 65a4d1c424
commit 050be8ebe1

View file

@ -48,6 +48,7 @@ import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.cdt.utils.cdtvariables.CdtVariableResolver;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@ -757,7 +758,20 @@ public abstract class AbstractLanguageSettingsOutputScanner extends LanguageSett
}
// try to find absolute path in the workspace
if (sourceFile == null && new Path(parsedResourceName).isAbsolute()) {
Path parsedPath = new Path(parsedResourceName);
if (sourceFile == null && parsedPath.isAbsolute()) {
// It will often happen that the file will be under the project and in the local file system, so check there first.
IPath projectLocation = currentProject != null ? currentProject.getLocation() : null;
if (projectLocation != null) {
IPath relativePath = parsedPath.makeRelativeTo(projectLocation);
if (!relativePath.equals(parsedPath)) {
IFile file = currentProject.getFile(relativePath);
if (file.isAccessible()) {
return file;
}
}
}
URI uri = org.eclipse.core.filesystem.URIUtil.toURI(parsedResourceName);
sourceFile = findFileForLocationURI(uri, currentProject, /*checkExistence*/ true);
}