Skip to content

Commit cdb68f5

Browse files
EcljpseB0Tjukzi
authored andcommitted
[performance] IFile.create: reduce 1 of 3 store.fetchInfo()
Assume the file does not exist (normal case) - otherwise implementation fails later during actual write. #1443
1 parent b512a65 commit cdb68f5

File tree

1 file changed

+6
-15
lines changed
  • resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources

1 file changed

+6
-15
lines changed

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

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.eclipse.core.filesystem.EFS;
2525
import org.eclipse.core.filesystem.IFileInfo;
2626
import org.eclipse.core.filesystem.IFileStore;
27+
import org.eclipse.core.filesystem.provider.FileInfo;
2728
import org.eclipse.core.internal.preferences.EclipsePreferences;
2829
import org.eclipse.core.internal.utils.BitMask;
2930
import org.eclipse.core.internal.utils.Messages;
@@ -213,23 +214,13 @@ private void checkCreatable() throws CoreException {
213214
private IFileInfo create(int updateFlags, SubMonitor subMonitor, IFileStore store)
214215
throws CoreException, ResourceException {
215216
String message;
216-
IFileInfo localInfo = store.fetchInfo();
217+
IFileInfo localInfo;
217218
if (BitMask.isSet(updateFlags, IResource.FORCE)) {
218-
if (!Workspace.caseSensitive) {
219-
if (localInfo.exists()) {
220-
String name = getLocalManager().getLocalName(store);
221-
if (name == null || localInfo.getName().equals(name)) {
222-
delete(true, null);
223-
} else {
224-
// The file system is not case sensitive and there is already a file
225-
// under this location.
226-
message = NLS.bind(Messages.resources_existsLocalDifferentCase,
227-
IPath.fromOSString(store.toString()).removeLastSegments(1).append(name).toOSString());
228-
throw new ResourceException(IResourceStatus.CASE_VARIANT_EXISTS, getFullPath(), message, null);
229-
}
230-
}
231-
}
219+
// Assume the file does not exist - otherwise implementation fails later
220+
// during actual write
221+
localInfo = new FileInfo(getName()); // with exists==false
232222
} else {
223+
localInfo=store.fetchInfo();
233224
if (localInfo.exists()) {
234225
// return an appropriate error message for case variant collisions
235226
if (!Workspace.caseSensitive) {

0 commit comments

Comments
 (0)