Skip to content

Commit

Permalink
perf[protocol]: a capacity that is sufficient to keep the map from be…
Browse files Browse the repository at this point in the history
…ing resized
  • Loading branch information
jaysunxiao committed Oct 21, 2023
1 parent afa85e5 commit 0a69285
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ public static int comfortableCapacity(int capacity) {
: (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);
}


// ----------------------------------归并排序----------------------------------

/**
Expand Down

0 comments on commit 0a69285

Please sign in to comment.