perf[protocol]: a capacity that is sufficient to keep the map from being resized

This commit is contained in:
godotg
2023-10-21 11:07:35 +08:00
parent afa85e55fb
commit 0a69285a7e
@@ -115,6 +115,14 @@ public abstract class CollectionUtils {
: (capacity < 32 ? 64 : Math.min(capacity << 1, IOUtils.BYTES_PER_MB));
}
public static int capacity(int expectedSize) {
if (expectedSize < 3) {
return expectedSize + 1;
}
return (int) ((float) expectedSize / 0.75F + 1.0F);
}
// ----------------------------------归并排序----------------------------------
/**