More optimizations, see summary in 1GHFO1M
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CoreFileSystemLibrary.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CoreFileSystemLibrary.java
index 01ab35d..ea595e2 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CoreFileSystemLibrary.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CoreFileSystemLibrary.java
@@ -15,6 +15,9 @@
/** Indicates whether or not this FS is case sensitive */
private static final boolean caseSensitive = new File("a").compareTo(new File("A")) != 0;
+
+ /** Indicates the default string encoding on this platform */
+ private static String defaultEncoding = new java.io.InputStreamReader(new java.io.ByteArrayInputStream(new byte[0])).getEncoding();
/**
* The following masks are used to represent the bits
@@ -62,8 +65,19 @@
return new File(fileName).lastModified();
}
public static long getStat(String fileName) {
- if (hasNatives)
- return internalGetStat(fileName.getBytes());
+ if (hasNatives) {
+ //try to use the default encoding, avoids creating an encoding object instance
+ if (defaultEncoding == null) {
+ return internalGetStat(fileName.getBytes());
+ }
+ try {
+ return internalGetStat(fileName.getBytes(defaultEncoding));
+ } catch (java.io.UnsupportedEncodingException e) {
+ //null the default encoding so we don't try it again
+ defaultEncoding = null;
+ return internalGetStat(fileName.getBytes());
+ }
+ }
// inlined (no native) implementation
File target = new File(fileName);