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:
parent
fac0ca8319
commit
141554f5d1
@ -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,13 +137,11 @@ public final class SystemPropertyUtil {
|
||||
return def;
|
||||
}
|
||||
|
||||
value = value.trim().toLowerCase();
|
||||
if (INTEGER_PATTERN.matcher(value).matches()) {
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
value = value.trim();
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
logger.warn(
|
||||
@ -172,13 +167,11 @@ public final class SystemPropertyUtil {
|
||||
return def;
|
||||
}
|
||||
|
||||
value = value.trim().toLowerCase();
|
||||
if (INTEGER_PATTERN.matcher(value).matches()) {
|
||||
try {
|
||||
return Long.parseLong(value);
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
value = value.trim();
|
||||
try {
|
||||
return Long.parseLong(value);
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
logger.warn(
|
||||
|
Loading…
Reference in New Issue
Block a user