Skip to content

Commit a9889fa

Browse files
EcljpseB0Tjukzi
authored andcommitted
[performance] do not normalize locations that are already normalized
When projects or links are added to the workspace the file location is normalized and saved to disk. Good. However it is not needed to do that for those already normalized paths that are loaded back from disk. Saves some startup time on windows, where name capitalization of each path segment is expensive IO.
1 parent 30ef1d9 commit a9889fa

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

resources/bundles/org.eclipse.core.resources/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
5-
Bundle-Version: 3.20.100.qualifier
5+
Bundle-Version: 3.20.200.qualifier
66
Bundle-Activator: org.eclipse.core.resources.ResourcesPlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,14 @@ public boolean hasSavedDescription(IProject project) {
660660
* @param location the File system location of this resource on disk
661661
* @return The file store for the provided resource
662662
*/
663-
private IFileStore initializeStore(IResource target, URI location) throws CoreException {
663+
private IFileStore initializeStore(IResource target, URI location, boolean locationAlreadyNormalized)
664+
throws CoreException {
664665
ResourceInfo info = ((Resource) target).getResourceInfo(false, true);
665-
setLocation(target, info, location);
666+
if (locationAlreadyNormalized) {
667+
setNormalizedLocation(target, info, location);
668+
} else {
669+
setLocation(target, info, location);
670+
}
666671
FileStoreRoot root = getStoreRoot(target);
667672
return root.createStore(target.getFullPath(), target);
668673
}
@@ -808,7 +813,7 @@ public boolean isLightweightAutoRefreshEnabled() {
808813
}
809814

810815
public void link(Resource target, URI location, IFileInfo fileInfo) throws CoreException {
811-
initializeStore(target, location);
816+
initializeStore(target, location, false);
812817
ResourceInfo info = target.getResourceInfo(false, true);
813818
long lastModified = fileInfo == null ? 0 : fileInfo.getLastModified();
814819
if (lastModified == 0)
@@ -928,7 +933,7 @@ public ProjectDescription read(IProject target, boolean creation) throws CoreExc
928933
projectLocation = URIUtil.toURI(getProjectDefaultLocation(target));
929934
}
930935
IFile descFile = target.getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
931-
IFileStore projectStore = initializeStore(target, projectLocation);
936+
IFileStore projectStore = initializeStore(target, projectLocation, true);
932937
IFileStore descriptionStore = descFile.exists() ? getStore(descFile) : projectStore.getChild(IProjectDescription.DESCRIPTION_FILE_NAME);
933938
ProjectDescription description = null;
934939
//hold onto any exceptions until after sync info is updated, then throw it
@@ -1089,9 +1094,13 @@ public long setLocalTimeStamp(IResource target, ResourceInfo info, long value) t
10891094
* @param location the new storage location
10901095
*/
10911096
public void setLocation(IResource target, ResourceInfo info, URI location) {
1097+
// Normalize case as it exists on the file system.
1098+
setNormalizedLocation(target, info, FileUtil.realURI(location));
1099+
}
1100+
1101+
public void setNormalizedLocation(IResource target, ResourceInfo info, URI location) {
10921102
FileStoreRoot oldRoot = info.getFileStoreRoot();
10931103
if (location != null) {
1094-
location = FileUtil.realURI(location); // Normalize case as it exists on the file system.
10951104
info.setFileStoreRoot(new FileStoreRoot(location, target.getFullPath()));
10961105
} else {
10971106
//project is in default location so clear the store root

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,21 @@ boolean internalHasBuildConfig(String configName) {
853853
* during workspace restore (i.e., when you cannot do an operation)
854854
*/
855855
void internalSetDescription(IProjectDescription value, boolean incrementContentId) {
856+
internalSetDescription(value, incrementContentId, false);
857+
}
858+
859+
void internalSetDescription(IProjectDescription value, boolean incrementContentId,
860+
boolean locationAlreadyNormalized) {
856861
// Project has been added / removed. Build order is out-of-step
857862
workspace.flushBuildOrder();
858863

859864
ProjectInfo info = (ProjectInfo) getResourceInfo(false, true);
860865
info.setDescription((ProjectDescription) value);
861-
getLocalManager().setLocation(this, info, value.getLocationURI());
866+
if (locationAlreadyNormalized) {
867+
getLocalManager().setNormalizedLocation(this, info, value.getLocationURI());
868+
} else {
869+
getLocalManager().setLocation(this, info, value.getLocationURI());
870+
}
862871
if (incrementContentId) {
863872
info.incrementContentId();
864873
//if the project is not accessible, stamp will be null and should remain null

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ protected void restoreMetaInfo(Project project, IProgressMonitor monitor) throws
967967
//try to read private metadata and add to the description
968968
workspace.getMetaArea().readPrivateDescription(project, description);
969969
}
970-
project.internalSetDescription(description, false);
970+
project.internalSetDescription(description, false, true);
971971
if (failure != null) {
972972
try {
973973
// write the project tree ...

0 commit comments

Comments
 (0)