chore[comment]: code comment

This commit is contained in:
godotg
2023-11-01 11:30:25 +08:00
parent 6fda2cc38a
commit d8f1ef7f26
@@ -97,17 +97,22 @@ public abstract class CollectionUtils {
}
/**
* 数组初始化长度的安全上限限制,防止反序列化异常导致内存突然升高
* EN: The safety limit of the array initialization length prevents deserialization exceptions from causing a sudden increase in memory
* CN: 数组初始化长度的安全上限限制,防止反序列化异常导致内存突然升高
*/
public static int comfortableLength(int length) {
if (length >= IOUtils.BYTES_PER_MB) {
throw new ArrayStoreException(StringUtils.format("新建数组的长度[{}]超过设置的安全范围[{}]", length, IOUtils.BYTES_PER_MB));
throw new ArrayStoreException(StringUtils.format("The length of the newly created array [{}] exceeds the set safety range [{}]"
, length, IOUtils.BYTES_PER_MB));
}
return length;
}
/**
* 计算List和HashMap初始化合适的大小,为了安全必须给初始化的集合一个最大上限,防止反序列化一个不合法的包导致内存突然升高
* EN: Calculate the appropriate size for HashMap initialization. For safety, a maximum limit must be given
* to the initialized collection to prevent deserialization of an illegal package from causing a sudden increase in memory.
* <p>
* CN: 计算HashMap初始化合适的大小,为了安全必须给初始化的集合一个最大上限,防止反序列化一个不合法的包导致内存突然升高
*/
public static int comfortableCapacity(int capacity) {
return capacity < 16
@@ -241,7 +246,6 @@ public abstract class CollectionUtils {
}
/**
* 获取集合的最后几个元素
*/