camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [07/18] git commit: 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.
Date Mon, 24 Feb 2014 16:04:49 GMT
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/4bc7d6e6
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4bc7d6e6
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4bc7d6e6

Branch: refs/heads/master
Commit: 4bc7d6e63a3cf7607cd4dbb076c8d511c7dbb084
Parents: da08bda
Author: lldata <lasse@lldata.dk>
Authored: Mon Feb 24 16:32:19 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Feb 24 17:05:28 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/4bc7d6e6/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);


Mime
View raw message