refactor(JSONWriterUTF8): Optimize string encoding methods

Refactored the string encoding logic by removing redundant variable assignments and modifying method visibility for better performance and maintainability.
This commit is contained in:
wenshao 2025-02-27 05:42:16 +08:00
parent 0a5013ead7
commit c12ef42a7e
2 changed files with 2 additions and 4 deletions

View File

@ -471,7 +471,7 @@ class JSONWriterUTF8
this.bytes[this.off++] = (byte) quote;
}
public void writeStringLatin1(byte[] value) {
public final void writeStringLatin1(byte[] value) {
if ((context.features & MASK_BROWSER_SECURE) != 0) {
writeStringLatin1BrowserSecure(value);
return;

View File

@ -15,10 +15,8 @@ final class JSONWriterUTF8JDK9
return;
}
int coder = STRING_CODER.applyAsInt(str);
byte[] value = STRING_VALUE.apply(str);
if (coder == 0) {
if (STRING_CODER.applyAsInt(str) == 0) {
writeStringLatin1(value);
} else {
writeStringUTF16(value);