Skip to content

Commit

Permalink
Refactor 20250116 (#3290)
Browse files Browse the repository at this point in the history
* refactor

* refactor writeInt32

* refactor
  • Loading branch information
wenshao authored Jan 16, 2025
1 parent 41662c7 commit 23eb651
Show file tree
Hide file tree
Showing 7 changed files with 525 additions and 668 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static void jsonb() throws Exception {
System.out.println("AlongParseBinaryArrayMapping-jsonb millis : " + millis);
// zulu8.68.0.21 : 2928 2887 2826 2806 2754 2693 1876
// zulu11.52.13 : 2484 2170 1916 1911 1892 1879 1876 1845 1756
// zulu17.32.13 : 2601 2457 1691 1593
// zulu17.32.13 : 2601 2457 1691 1593 1334
}
}

Expand All @@ -33,7 +33,7 @@ public static void jsonbFeatures() throws Exception {
System.out.println("AlongParseBinaryArrayMapping-jsonbFeatures millis : " + millis);
// zulu8.68.0.21 :
// zulu11.52.13 :
// zulu17.32.13 :
// zulu17.32.13 : 1252
}
}

Expand All @@ -55,8 +55,8 @@ public static void fury() throws Exception {
}

public static void main(String[] args) throws Exception {
// jsonb();
jsonbFeatures();
jsonb();
// jsonbFeatures();
// fury();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public static void fury() throws Exception {
}

public static void main(String[] args) throws Exception {
// jsonb();
jsonbFeatures();
jsonb();
// jsonbFeatures();
// json();
// jsonStr();
// fury();
Expand Down
32 changes: 30 additions & 2 deletions core/src/main/java/com/alibaba/fastjson2/JSONB.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ interface Constants {
byte BC_INT32_NUM_MAX = 47; // 0x2f

byte BC_INT32_BYTE_MIN = 48; // 0x30
byte BC_INT32_BYTE_ZERO = 56;
byte BC_INT32_BYTE_MAX = 63;
byte BC_INT32_BYTE_ZERO = 56; // 0x38
byte BC_INT32_BYTE_MAX = 63; // 0x3f

byte BC_INT32_SHORT_MIN = 64; // 0x40
byte BC_INT32_SHORT_ZERO = 68;
Expand Down Expand Up @@ -1443,4 +1443,32 @@ static String typeName(byte type) {
return Integer.toString(type);
}
}

static boolean isInt32(int type) {
return type >= BC_INT32_NUM_MIN && type <= BC_INT32;
}

static boolean isInt32Num(int type) {
return type >= BC_INT32_NUM_MIN && type <= BC_INT32_NUM_MAX;
}

static boolean isInt32Byte(int type) {
return (type & 0xF0) == 0x30;
}

static boolean isInt32Short(int type) {
return (type & 0xF8) == 0x40;
}

static boolean isInt64Num(int type) {
return type >= BC_INT64_NUM_MIN && type <= BC_INT64_NUM_MAX;
}

static boolean isInt64Byte(int type) {
return ((type - BC_INT64_BYTE_MIN) & 0xF0) == 0;
}

static boolean isInt64Short(int type) {
return (type & 0xF8) == 0xC0;
}
}
Loading

0 comments on commit 23eb651

Please sign in to comment.