perf: 简单优化代码

This commit is contained in:
2025-09-03 20:56:52 +08:00
parent 8f451e7eb9
commit 7e1e8e0583
5 changed files with 7 additions and 3 deletions

View File

@@ -154,7 +154,7 @@ public final class EnumTools {
*/ */
@Nullable @Nullable
public static <E extends Enum<?>> Integer checkOrdinalNullable(Class<E> enumType, @Nullable Integer ordinal) { public static <E extends Enum<?>> Integer checkOrdinalNullable(Class<E> enumType, @Nullable Integer ordinal) {
return checkOrdinalOrDefault(enumType, ordinal, (Integer) null); return checkOrdinalOrDefault(enumType, ordinal, null);
} }
/** /**

View File

@@ -33,6 +33,7 @@ import xyz.zhouxy.plusone.commons.annotation.StaticFactoryMethod;
/** /**
* 枚举类 * 枚举类
* *
* <p>
* 参考 <a href="https://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/">Enumeration classes</a> * 参考 <a href="https://lostechies.com/jimmybogard/2008/08/12/enumeration-classes/">Enumeration classes</a>
* *
* @author ZhouXY108 <luquanlion@outlook.com> * @author ZhouXY108 <luquanlion@outlook.com>

View File

@@ -36,7 +36,7 @@ public final class RandomTools {
private static final SecureRandom DEFAULT_SECURE_RANDOM; private static final SecureRandom DEFAULT_SECURE_RANDOM;
static { static {
SecureRandom secureRandom = null; SecureRandom secureRandom;
try { try {
secureRandom = SecureRandom.getInstanceStrong(); // 获取高强度安全随机数生成器 secureRandom = SecureRandom.getInstanceStrong(); // 获取高强度安全随机数生成器
} }

View File

@@ -363,7 +363,7 @@ public final class RegexTools {
this.flags = flags; this.flags = flags;
} }
private final Pattern compilePattern() { private Pattern compilePattern() {
return Pattern.compile(regex, flags); return Pattern.compile(regex, flags);
} }

View File

@@ -177,6 +177,9 @@ public class StringTools {
*/ */
@Beta @Beta
public static boolean isURL(@Nullable final String cs) { public static boolean isURL(@Nullable final String cs) {
if (cs == null) {
return false;
}
try { try {
new URL(cs); new URL(cs);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {