From c2b082b54aa45fde55f8a69e4bb51a02b1704c6a Mon Sep 17 00:00:00 2001 From: Stzx Date: Sat, 17 Aug 2019 13:28:01 +0800 Subject: [PATCH] Improvement JavaVersion get method When nom is null, return directly without unnecessary judgment. --- src/main/java/org/apache/commons/lang3/JavaVersion.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/JavaVersion.java b/src/main/java/org/apache/commons/lang3/JavaVersion.java index c860519a8..143e997d6 100644 --- a/src/main/java/org/apache/commons/lang3/JavaVersion.java +++ b/src/main/java/org/apache/commons/lang3/JavaVersion.java @@ -194,7 +194,9 @@ public enum JavaVersion { * version is unknown */ static JavaVersion get(final String nom) { - if ("0.9".equals(nom)) { + if (nom == null) { + return null; + } else if ("0.9".equals(nom)) { return JAVA_0_9; } else if ("1.1".equals(nom)) { return JAVA_1_1; @@ -223,9 +225,6 @@ public enum JavaVersion { } else if ("13".equals(nom)) { return JAVA_13; } - if (nom == null) { - return null; - } final float v = toFloatVersion(nom); if ((v - 1.) < 1.) { // then we need to check decimals > .9 final int firstComma = Math.max(nom.indexOf('.'), nom.indexOf(','));