Skip to content

Commit d9719ca

Browse files
Jörg Kubitzjukzi
authored andcommitted
[performance] avoid File.getCanonicalPath()
File.getCanonicalPath() is a IO Operation that is costly especially on windows OS. Instead use a NON-IO .toPath().normalize().toAbsolutePath().toString() https://bugs.eclipse.org/bugs/show_bug.cgi?id=571614
1 parent a639856 commit d9719ca

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

org.eclipse.jdt.debug.tests/tests/org/eclipse/jdt/debug/tests/breakpoints/ImportBreakpointsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public void testBreakpointImportMissingResources() throws Exception {
228228
File file = JavaTestPlugin.getDefault().getFileInPlugin(new Path("testresources/brkpt_missing.bkpt"));
229229
assertNotNull(file);
230230
assertEquals(true, file.exists());
231-
ImportBreakpointsOperation op = new ImportBreakpointsOperation(file.getCanonicalPath(), true, true);
231+
ImportBreakpointsOperation op = new ImportBreakpointsOperation(file.toPath().normalize().toAbsolutePath().toString(), true, true);
232232
op.run(new NullProgressMonitor());
233233
assertEquals("should be no breakpoints imported", 0, getBreakpointManager().getBreakpoints().length);
234234
}

org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/jres/InstalledJREsBlock.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
package org.eclipse.jdt.internal.debug.ui.jres;
1515

1616
import java.io.File;
17-
import java.io.IOException;
1817
import java.lang.reflect.InvocationTargetException;
1918
import java.util.ArrayList;
2019
import java.util.HashSet;
@@ -1052,11 +1051,8 @@ protected void search(File directory, List<File> found, List<IVMInstallType> typ
10521051
return;
10531052
}
10541053
File file = new File(directory, names[i]);
1055-
try {
1056-
monitor.subTask(NLS.bind(JREMessages.InstalledJREsBlock_14, new String[]{Integer.toString(found.size()),
1057-
file.getCanonicalPath().replaceAll("&", "&&")})); // @see bug 29855 //$NON-NLS-1$ //$NON-NLS-2$
1058-
} catch (IOException e) {
1059-
}
1054+
monitor.subTask(NLS.bind(JREMessages.InstalledJREsBlock_14, new String[] { Integer.toString(found.size()),
1055+
file.toPath().normalize().toAbsolutePath().toString().replaceAll("&", "&&") })); // @see bug 29855 //$NON-NLS-1$ //$NON-NLS-2$
10601056
IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();
10611057
if (file.isDirectory()) {
10621058
if (!ignore.contains(file)) {

0 commit comments

Comments
 (0)