Skip to content

Commit 6a0fa03

Browse files
committed
enhance performance on valueOrNull
1 parent 9b4d6ed commit 6a0fa03

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

  • modules/library/src/main/java/top/mrxiaom/pluginbase/utils

modules/library/src/main/java/top/mrxiaom/pluginbase/utils/Util.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ public static <T> T valueOr(Class<T> type, String s, T def) {
369369
* @param s 输入的多个字符串
370370
*/
371371
public static <T> T valueOrNull(Class<T> type, String... s) {
372+
if (s.length == 0) return null;
373+
if (s.length == 1) return valueOr(type, s[0], null);
372374
for (String str : s) {
373375
T value = valueOr(type, str, null);
374376
if (value != null) return value;

0 commit comments

Comments
 (0)