Skip to content

Commit 9b9155e

Browse files
committed
Precompile pattern.
1 parent 43538ea commit 9b9155e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/apache/commons/lang3/JavaVersion.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
package org.apache.commons.lang3;
1818

19+
import java.util.regex.Pattern;
20+
1921
import org.apache.commons.lang3.math.NumberUtils;
2022

2123
/**
@@ -198,9 +200,9 @@ public enum JavaVersion {
198200
JAVA_RECENT(maxVersion(), Float.toString(maxVersion()));
199201

200202
/**
201-
* The regex to split version strings.
203+
* The regex to split version pattern.
202204
*/
203-
private static final String VERSION_SPLIT_REGEX = "\\.";
205+
private static final Pattern VERSION_SPLIT_PATTERN = Pattern.compile("\\.");
204206

205207
/**
206208
* Transforms the given string with a Java version number to the
@@ -305,7 +307,7 @@ private static float maxVersion() {
305307
}
306308

307309
static String[] split(final String value) {
308-
return value.split(VERSION_SPLIT_REGEX);
310+
return VERSION_SPLIT_PATTERN.split(value);
309311
}
310312

311313
/**

0 commit comments

Comments
 (0)