From c46b47ab41a415ed680ae70f264ea3a7cecba99d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Kubitz?= Date: Tue, 25 Jun 2024 12:37:38 +0200 Subject: [PATCH] [performance] IFile.create: reduce 1 of 3 store.fetchInfo() Assume the file does not exist (normal case) - otherwise implementation fails later during actual write. https://github.com/eclipse-platform/eclipse.platform/issues/1443 --- .../eclipse/core/internal/resources/File.java | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/File.java b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/File.java index b5a2ed5cd22..76c0b56eeaa 100644 --- a/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/File.java +++ b/resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/File.java @@ -24,6 +24,7 @@ import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.filesystem.provider.FileInfo; import org.eclipse.core.internal.preferences.EclipsePreferences; import org.eclipse.core.internal.utils.BitMask; import org.eclipse.core.internal.utils.Messages; @@ -213,23 +214,13 @@ private void checkCreatable() throws CoreException { private IFileInfo create(int updateFlags, SubMonitor subMonitor, IFileStore store) throws CoreException, ResourceException { String message; - IFileInfo localInfo = store.fetchInfo(); + IFileInfo localInfo; if (BitMask.isSet(updateFlags, IResource.FORCE)) { - if (!Workspace.caseSensitive) { - if (localInfo.exists()) { - String name = getLocalManager().getLocalName(store); - if (name == null || localInfo.getName().equals(name)) { - delete(true, null); - } else { - // The file system is not case sensitive and there is already a file - // under this location. - message = NLS.bind(Messages.resources_existsLocalDifferentCase, - IPath.fromOSString(store.toString()).removeLastSegments(1).append(name).toOSString()); - throw new ResourceException(IResourceStatus.CASE_VARIANT_EXISTS, getFullPath(), message, null); - } - } - } + // Assume the file does not exist - otherwise implementation fails later + // during actual write + localInfo = new FileInfo(getName()); // with exists==false } else { + localInfo=store.fetchInfo(); if (localInfo.exists()) { // return an appropriate error message for case variant collisions if (!Workspace.caseSensitive) {