--- old/src/java.base/share/classes/java/lang/AbstractStringBuilder.java 2015-04-24 20:13:36.926423266 +0300
+++ new/src/java.base/share/classes/java/lang/AbstractStringBuilder.java 2015-04-24 20:13:36.814430712 +0300
@@ -99,8 +99,8 @@
* array is allocated with greater capacity. The new capacity is the
* larger of:
*
- * - The {@code minimumCapacity} argument.
- *
- Twice the old capacity, plus {@code 2}.
+ *
- The {@code minimumCapacity} argument, plus {@code 32}.
+ *
- Twice the old capacity, plus {@code 32}.
*
* If the {@code minimumCapacity} argument is nonpositive, this
* method takes no action and simply returns.
@@ -129,9 +129,10 @@
* size check or synchronization.
*/
void expandCapacity(int minimumCapacity) {
- int newCapacity = value.length * 2 + 2;
+ int newCapacity = value.length * 2;
if (newCapacity - minimumCapacity < 0)
newCapacity = minimumCapacity;
+ newCapacity += 32; // expect follow-up ops
if (newCapacity < 0) {
if (minimumCapacity < 0) // overflow
throw new OutOfMemoryError();