Skip to content

Commit

Permalink
use writeU4Hex2
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jan 13, 2025
1 parent 1e35482 commit 4d45413
Showing 1 changed file with 3 additions and 90 deletions.
93 changes: 3 additions & 90 deletions core/src/main/java/com/alibaba/fastjson2/JSONWriterUTF16.java
Original file line number Diff line number Diff line change
Expand Up @@ -625,25 +625,9 @@ protected final void writeStringEscapeUTF16(byte[] str) {
case 5:
case 6:
case 7:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '0';
chars[off + 5] = (char) ('0' + (int) ch);
off += 6;
break;
case 11:
case 14:
case 15:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '0';
chars[off + 5] = (char) ('a' + (ch - 10));
off += 6;
break;
case 16:
case 17:
case 18:
Expand All @@ -654,26 +638,13 @@ protected final void writeStringEscapeUTF16(byte[] str) {
case 23:
case 24:
case 25:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '1';
chars[off + 5] = (char) ('0' + (ch - 16));
off += 6;
break;
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '1';
chars[off + 5] = (char) ('a' + (ch - 26));
writeU4Hex2(chars, off, ch);
off += 6;
break;
case '<':
Expand Down Expand Up @@ -739,25 +710,9 @@ protected final void writeStringEscape(char[] str) {
case 5:
case 6:
case 7:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '0';
chars[off + 5] = (char) ('0' + (int) ch);
off += 6;
break;
case 11:
case 14:
case 15:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '0';
chars[off + 5] = (char) ('a' + (ch - 10));
off += 6;
break;
case 16:
case 17:
case 18:
Expand All @@ -768,26 +723,13 @@ protected final void writeStringEscape(char[] str) {
case 23:
case 24:
case 25:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '1';
chars[off + 5] = (char) ('0' + (ch - 16));
off += 6;
break;
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '1';
chars[off + 5] = (char) ('a' + (ch - 26));
writeU4Hex2(chars, off, ch);
off += 6;
break;
case '<':
Expand Down Expand Up @@ -989,25 +931,9 @@ public final void writeString(char[] str, int offset, int len, boolean quoted) {
case 5:
case 6:
case 7:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '0';
chars[off + 5] = (char) ('0' + (int) ch);
off += 6;
break;
case 11:
case 14:
case 15:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '0';
chars[off + 5] = (char) ('a' + (ch - 10));
off += 6;
break;
case 16:
case 17:
case 18:
Expand All @@ -1018,26 +944,13 @@ public final void writeString(char[] str, int offset, int len, boolean quoted) {
case 23:
case 24:
case 25:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '1';
chars[off + 5] = (char) ('0' + (ch - 16));
off += 6;
break;
case 26:
case 27:
case 28:
case 29:
case 30:
case 31:
chars[off] = '\\';
chars[off + 1] = 'u';
chars[off + 2] = '0';
chars[off + 3] = '0';
chars[off + 4] = '1';
chars[off + 5] = (char) ('a' + (ch - 26));
writeU4Hex2(chars, off, ch);
off += 6;
break;
default:
Expand Down

0 comments on commit 4d45413

Please sign in to comment.