From a078ddb6e645a3a84418a1cb0a66b349cd006f0a Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 15 Mar 2015 23:01:24 -0700 Subject: [PATCH] Only compile pattern once --- .../com/comphenix/protocol/utility/MinecraftVersion.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java index 1e6c575c..50638315 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/MinecraftVersion.java @@ -42,7 +42,7 @@ public class MinecraftVersion implements Comparable, Serializa /** * Regular expression used to parse version strings. */ - private static final String VERSION_PATTERN = ".*\\(.*MC.\\s*([a-zA-z0-9\\-\\.]+)\\s*\\)"; + private static final Pattern VERSION_PATTERN = Pattern.compile(".*\\(.*MC.\\s*([a-zA-z0-9\\-\\.]+)\\s*\\)"); /** * Version 1.8 - the "bountiful" update. @@ -293,8 +293,7 @@ public class MinecraftVersion implements Comparable, Serializa * @throws IllegalStateException If we could not parse the version string. */ public static String extractVersion(String text) { - Pattern versionPattern = Pattern.compile(VERSION_PATTERN); - Matcher version = versionPattern.matcher(text); + Matcher version = VERSION_PATTERN.matcher(text); if (version.matches() && version.group(1) != null) { return version.group(1);