Removed unnecessary pattern matching during number paring and unnecessary toLowerCase() invocation.

Motivation:

Pattern matching not necessary for number parsing.

Modification:

Removed pattern matching for number parsing and removed unnecessary toLowerCase() operation.

Result:

No static variable with pattern, removed unnecessary matching operation and toLowerCase() operation.
This commit is contained in:
Dmitriy Dumanskiy 2017-01-18 18:16:49 +02:00 committed by Norman Maurer
parent fac0ca8319
commit 141554f5d1

View File

@ -20,7 +20,6 @@ import io.netty.util.internal.logging.InternalLoggerFactory;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.regex.Pattern;
/**
* A collection of utility methods to retrieve and parse the values of the Java system properties.
@ -123,8 +122,6 @@ public final class SystemPropertyUtil {
return def;
}
private static final Pattern INTEGER_PATTERN = Pattern.compile("-?[0-9]+");
/**
* Returns the value of the Java system property with the specified
* {@code key}, while falling back to the specified default value if
@ -140,14 +137,12 @@ public final class SystemPropertyUtil {
return def;
}
value = value.trim().toLowerCase();
if (INTEGER_PATTERN.matcher(value).matches()) {
value = value.trim();
try {
return Integer.parseInt(value);
} catch (Exception e) {
// Ignore
}
}
logger.warn(
"Unable to parse the integer system property '{}':{} - using the default value: {}",
@ -172,14 +167,12 @@ public final class SystemPropertyUtil {
return def;
}
value = value.trim().toLowerCase();
if (INTEGER_PATTERN.matcher(value).matches()) {
value = value.trim();
try {
return Long.parseLong(value);
} catch (Exception e) {
// Ignore
}
}
logger.warn(
"Unable to parse the long integer system property '{}':{} - using the default value: {}",