Skip to content

Commit

Permalink
Showing 1 changed file with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -364,17 +364,12 @@ public static int capacity(int current, int needed) {
if (needed < INITIAL_CAPACITY) {
return INITIAL_CAPACITY;
} else {
int capacity = current;

if (capacity == 0) {
capacity = INITIAL_CAPACITY;
}

while (capacity < needed) {
capacity *= 2;
final int newCapacity = current << 1;
if (newCapacity >= needed) {
return newCapacity;
} else {
return needed;
}

return capacity;
}
}

0 comments on commit 19457f5

Please sign in to comment.