From 158119a26beed8a41d423d39ccfb04692a338ff7 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Mon, 22 Feb 2016 04:34:08 +0000 Subject: [PATCH] Cache Pattern instance --- source/net/filebot/util/FileUtilities.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/net/filebot/util/FileUtilities.java b/source/net/filebot/util/FileUtilities.java index 49dbca17..8e81442d 100644 --- a/source/net/filebot/util/FileUtilities.java +++ b/source/net/filebot/util/FileUtilities.java @@ -620,12 +620,14 @@ public final class FileUtilities { return path.replace('\\', '/'); } + private static final Pattern PATH_SEPARATORS = Pattern.compile("\\s*[\\\\/]+\\s*"); + public static String replacePathSeparators(CharSequence path) { return replacePathSeparators(path, " "); } public static String replacePathSeparators(CharSequence path, String replacement) { - return Pattern.compile("\\s*[\\\\/]+\\s*").matcher(path).replaceAll(replacement); + return PATH_SEPARATORS.matcher(path).replaceAll(replacement); } public static String md5(String string) {