Caching of FileUtil.isWindows call, since it gets called quite often. In the 
profiler It showed up as taking 5-10% cpu on my system.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ed77d1fe
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ed77d1fe
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ed77d1fe

Branch: refs/heads/camel-2.12.x
Commit: ed77d1fe362ad8a1836a5cae46709c076b8b13f2
Parents: 82b2ecb
Author: lldata <la...@lldata.dk>
Authored: Mon Feb 24 16:32:19 2014 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Mon Feb 24 17:05:42 2014 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/camel/util/FileUtil.java   | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ed77d1fe/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java 
b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
index b624a21..9668cc7 100644
--- a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
+++ b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java
@@ -45,6 +45,7 @@ public final class FileUtil {
     private static final File USER_DIR = new 
File(System.getProperty(USER_DIR_KEY));
     private static File defaultTempDir;
     private static Thread shutdownHook;
+    private static boolean windowsOs = initWindowsOs();
 
     private FileUtil() {
         // Utils method
@@ -70,12 +71,19 @@ public final class FileUtil {
             return path.replace('\\', '/');
         }
     }
-    
-    public static boolean isWindows() {
+
+    private static boolean initWindowsOs() {
         String osName = System.getProperty("os.name").toLowerCase(Locale.US);
         return osName.indexOf("windows") > -1;
     }
 
+    /**
+     * Returns true, if the OS is windows
+     */
+    public static boolean isWindows() {
+        return windowsOs;
+    }
+
     @Deprecated
     public static File createTempFile(String prefix, String suffix) throws 
IOException {
         return createTempFile(prefix, suffix, null);

Reply via email to