mirror of
https://github.com/corda/corda.git
synced 2025-01-22 12:28:11 +00:00
fix length tracking bugs in StringBuilder
This commit is contained in:
parent
fe24005ff0
commit
216224dcc4
@ -20,12 +20,9 @@ public class StringBuilder {
|
|||||||
|
|
||||||
private void flush() {
|
private void flush() {
|
||||||
if (position > 0) {
|
if (position > 0) {
|
||||||
char[] b = buffer;
|
chain = new Cell(new String(buffer, 0, position, false), chain);
|
||||||
int p = position;
|
|
||||||
buffer = null;
|
buffer = null;
|
||||||
position = 0;
|
position = 0;
|
||||||
append(new String(b, 0, p, false));
|
|
||||||
length -= p;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +95,6 @@ public class StringBuilder {
|
|||||||
flush();
|
flush();
|
||||||
|
|
||||||
int index = length;
|
int index = length;
|
||||||
-- length;
|
|
||||||
Cell p = null;
|
Cell p = null;
|
||||||
for (Cell c = chain; c != null; c = c.next) {
|
for (Cell c = chain; c != null; c = c.next) {
|
||||||
int start = index - c.value.length();
|
int start = index - c.value.length();
|
||||||
@ -123,7 +119,6 @@ public class StringBuilder {
|
|||||||
flush();
|
flush();
|
||||||
|
|
||||||
int index = length;
|
int index = length;
|
||||||
-- length;
|
|
||||||
for (Cell c = chain; c != null; c = c.next) {
|
for (Cell c = chain; c != null; c = c.next) {
|
||||||
int start = index - c.value.length();
|
int start = index - c.value.length();
|
||||||
index = start;
|
index = start;
|
||||||
@ -139,6 +134,8 @@ public class StringBuilder {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
length += s.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
@ -160,7 +157,6 @@ public class StringBuilder {
|
|||||||
flush();
|
flush();
|
||||||
|
|
||||||
int index = length;
|
int index = length;
|
||||||
-- length;
|
|
||||||
Cell p = null;
|
Cell p = null;
|
||||||
for (Cell c = chain; c != null; c = c.next) {
|
for (Cell c = chain; c != null; c = c.next) {
|
||||||
int e = index;
|
int e = index;
|
||||||
@ -190,6 +186,8 @@ public class StringBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
length -= (end - start);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user