perf[protocol]: 统一反序列化为空和不为空的语义,都返回一个可以操作的集合而不是不能操作的集合

This commit is contained in:
godotg
2022-09-25 14:17:57 +08:00
parent f754172649
commit 0b10f07679
@@ -76,15 +76,15 @@ public abstract class CollectionUtils {
public static List<?> newList(int size) {
return size <= 0 ? Collections.EMPTY_LIST : new ArrayList<>(comfortableLength(size));
return size <= 0 ? new ArrayList<>() : new ArrayList<>(comfortableLength(size));
}
public static Set<?> newSet(int size) {
return size <= 0 ? Collections.EMPTY_SET : new HashSet<>(comfortableCapacity(size));
return size <= 0 ? new HashSet<>() : new HashSet<>(comfortableCapacity(size));
}
public static Map<?, ?> newMap(int size) {
return size <= 0 ? Collections.EMPTY_MAP : new HashMap<>(comfortableCapacity(size));
return size <= 0 ? new HashMap<>() : new HashMap<>(comfortableCapacity(size));
}