From f6151193a003cc14197284441152853482e3fae3 Mon Sep 17 00:00:00 2001 From: lldata Date: Mon, 24 Feb 2014 16:32:19 +0100 Subject: [PATCH] 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. --- .../main/java/org/apache/camel/util/FileUtil.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 b624a210d84db..9668cc722f126 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 static String normalizePath(String path) { 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);