Skip to content

Commit

Permalink
Merge pull request #2697 from msqb/stringBuilderCurCapacityAfterDecom…
Browse files Browse the repository at this point in the history
…press

Get StringBuilder capacity again after decompress
  • Loading branch information
fjeremic authored Aug 28, 2018
2 parents 5b0b1e3 + 8ad75d3 commit 7aa44d5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions jcl/src/java.base/share/classes/java/lang/StringBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public final class StringBuilder extends AbstractStringBuilder implements Serial
private transient int count;
private transient char[] value;
private transient int capacity;
private void decompress(int min) {

private int decompress(int min) {
int currentLength = lengthInternal();
int currentCapacity = capacityInternal();

Expand All @@ -100,6 +100,7 @@ private void decompress(int min) {
capacity = newValue.length;

String.initCompressionFlag();
return capacity;
}

/**
Expand Down Expand Up @@ -208,7 +209,7 @@ public StringBuilder append (char[] chars) {
} else {
// Check if the StringBuilder is compressed
if (count >= 0) {
decompress(newLength);
currentCapacity = decompress(newLength);
}

if (newLength > currentCapacity) {
Expand Down Expand Up @@ -265,7 +266,7 @@ public StringBuilder append (char chars[], int start, int length) {
} else {
// Check if the StringBuilder is compressed
if (count >= 0) {
decompress(newLength);
currentCapacity = decompress(newLength);
}

if (newLength > currentCapacity) {
Expand Down Expand Up @@ -311,7 +312,7 @@ StringBuilder append (char[] chars, int start, int length, boolean compressed) {
} else {
// Check if the StringBuilder is compressed
if (count >= 0) {
decompress(newLength);
currentCapacity = decompress(newLength);
}

if (newLength > currentCapacity) {
Expand Down Expand Up @@ -369,7 +370,7 @@ public StringBuilder append(char ch) {
} else {
// Check if the StringBuilder is compressed
if (count >= 0) {
decompress(newLength);
currentCapacity = decompress(newLength);
}

if (newLength > currentCapacity) {
Expand Down Expand Up @@ -547,7 +548,7 @@ public StringBuilder append (String string) {
} else {
// Check if the StringBuilder is compressed
if (count >= 0) {
decompress(newLength);
currentCapacity = decompress(newLength);
}

if (newLength > currentCapacity) {
Expand Down Expand Up @@ -2217,7 +2218,7 @@ public StringBuilder append(CharSequence sequence) {
} else {
// Check if the StringBuilder is compressed
if (count >= 0) {
decompress(newLength);
currentCapacity = decompress(newLength);
}

if (newLength > currentCapacity) {
Expand Down Expand Up @@ -2281,8 +2282,7 @@ public StringBuilder append(CharSequence sequence, int start, int end) {
} else {
// Check if the StringBuilder is compressed
if (count >= 0) {
decompress(newLength);
currentCapacity = capacityInternal();
currentCapacity = decompress(newLength);
}

if (newLength > currentCapacity) {
Expand Down Expand Up @@ -2359,7 +2359,7 @@ public StringBuilder append(CharSequence sequence, int start, int end) {
} else {
// Check if the StringBuilder is compressed
if (count >= 0) {
decompress(newLength);
currentCapacity = decompress(newLength);
}

if (newLength > currentCapacity) {
Expand Down

0 comments on commit 7aa44d5

Please sign in to comment.