This commit is contained in:
redkale
2024-10-17 20:09:31 +08:00
parent 1491f6be70
commit 173a5c8a24
2 changed files with 26 additions and 26 deletions

View File

@@ -120,8 +120,8 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
}
if (member != null) {
byte[] bs = member.getJsonFieldNameColonBytes();
expand(bs.length);
System.arraycopy(bs, 0, content, count, bs.length);
byte[] bytes = expand(bs.length);
System.arraycopy(bs, 0, bytes, count, bs.length);
count += bs.length;
} else {
writeLatin1To(true, fieldName);
@@ -131,14 +131,14 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
@Override
public void writeTo(final byte ch) { // 只能是 0 - 127 的字符
expand(1);
content[count++] = ch;
byte[] bytes = expand(1);
bytes[count++] = ch;
}
@Override
public void writeTo(final byte[] chs, final int start, final int len) { // 只能是 0 - 127 的字符
expand(len);
System.arraycopy(chs, start, content, count, len);
byte[] bytes = expand(len);
System.arraycopy(chs, start, bytes, count, len);
count += len;
}
@@ -590,8 +590,8 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
@Override
public void writeBoolean(boolean value) {
byte[] bs = value ? BYTES_TUREVALUE : BYTES_FALSEVALUE;
expand(bs.length);
System.arraycopy(bs, 0, content, count, bs.length);
byte[] bytes = expand(bs.length);
System.arraycopy(bs, 0, bytes, count, bs.length);
count += bs.length;
}
@@ -599,15 +599,15 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
public void writeInt(int value) {
if (value >= 0 && value < TENTHOUSAND_MAX) {
byte[] bs = TENTHOUSAND_BYTES[value];
expand(bs.length);
System.arraycopy(bs, 0, content, count, bs.length);
byte[] bytes = expand(bs.length);
System.arraycopy(bs, 0, bytes, count, bs.length);
count += bs.length;
return;
}
if (value < 0 && value > -TENTHOUSAND_MAX) {
byte[] bs = TENTHOUSAND_BYTES2[-value];
expand(bs.length);
System.arraycopy(bs, 0, content, count, bs.length);
byte[] bytes = expand(bs.length);
System.arraycopy(bs, 0, bytes, count, bs.length);
count += bs.length;
return;
}
@@ -640,15 +640,15 @@ public class JsonBytesWriter extends JsonWriter implements ByteTuple {
public void writeLong(long value) {
if (value >= 0 && value < TENTHOUSAND_MAX) {
byte[] bs = TENTHOUSAND_BYTES[(int) value];
expand(bs.length);
System.arraycopy(bs, 0, content, count, bs.length);
byte[] bytes = expand(bs.length);
System.arraycopy(bs, 0, bytes, count, bs.length);
count += bs.length;
return;
}
if (value < 0 && value > -TENTHOUSAND_MAX) {
byte[] bs = TENTHOUSAND_BYTES2[(int) -value];
expand(bs.length);
System.arraycopy(bs, 0, content, count, bs.length);
byte[] bytes = expand(bs.length);
System.arraycopy(bs, 0, bytes, count, bs.length);
count += bs.length;
return;
}

View File

@@ -90,8 +90,8 @@ public class JsonCharsWriter extends JsonWriter {
}
public void writeTo(final char ch) { // 只能是 0 - 127 的字符
expand(1);
content[count++] = ch;
char[] chars = expand(1);
chars[count++] = ch;
}
public void writeTo(final char[] chs, final int start, final int len) { // 只能是 0 - 127 的字符
@@ -102,8 +102,8 @@ public class JsonCharsWriter extends JsonWriter {
@Override
public void writeTo(final byte b) { // 只能是 0 - 127 的字符
expand(1);
content[count++] = (char) b;
char[] chars = expand(1);
chars[count++] = (char) b;
}
@Override
@@ -142,14 +142,14 @@ public class JsonCharsWriter extends JsonWriter {
}
int len = value.length();
if (quote) {
expand(len + 2);
content[count++] = BYTE_DQUOTE;
value.getChars(0, len, content, count);
char[] chars = expand(len + 2);
chars[count++] = BYTE_DQUOTE;
value.getChars(0, len, chars, count);
count += len;
content[count++] = BYTE_DQUOTE;
chars[count++] = BYTE_DQUOTE;
} else {
expand(len);
value.getChars(0, len, content, count);
char[] chars = expand(len);
value.getChars(0, len, chars, count);
count += len;
}
}