Skip to content

Commit 9f368ee

Browse files
committed
chore: cleanup codes
1 parent f341e8d commit 9f368ee

File tree

3 files changed

+2
-58
lines changed

3 files changed

+2
-58
lines changed

src/aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::arch::aarch64::{
22
vceqq_u8, vdupq_n_u8, vld1q_u8_x4, vmaxvq_u8, vorrq_u8, vqtbl4q_u8, vst1q_u8,
33
};
44

5-
use crate::{ESCAPE, HEX_BYTES, UU};
5+
use crate::generic::{ESCAPE, HEX_BYTES, UU};
66

77
const CHUNK: usize = 64;
88
// 128 bytes ahead

src/generic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ pub(crate) static ESCAPE: [u8; 256] = [
9595
];
9696

9797
// Pre-computed hex digit pairs for control characters
98-
pub(crate) struct HexPair(u8, u8);
98+
pub(crate) struct HexPair(pub(crate) u8, pub(crate) u8);
9999

100100
pub(crate) static HEX_BYTES: [HexPair; 32] = [
101101
HexPair(b'0', b'0'),

src/lib.rs

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -116,62 +116,6 @@ mod x86;
116116

117117
pub use generic::escape_generic;
118118

119-
const BB: u8 = b'b'; // \x08
120-
const TT: u8 = b't'; // \x09
121-
const NN: u8 = b'n'; // \x0A
122-
const FF: u8 = b'f'; // \x0C
123-
const RR: u8 = b'r'; // \x0D
124-
pub(crate) const QU: u8 = b'"'; // \x22
125-
pub(crate) const BS: u8 = b'\\'; // \x5C
126-
pub(crate) const UU: u8 = b'u'; // \x00...\x1F except the ones above
127-
const __: u8 = 0;
128-
129-
// Lookup table of escape sequences. A value of b'x' at index i means that byte
130-
// i is escaped as "\x" in JSON. A value of 0 means that byte i is not escaped.
131-
pub(crate) const ESCAPE: [u8; 256] = [
132-
// 1 2 3 4 5 6 7 8 9 A B C D E F
133-
UU, UU, UU, UU, UU, UU, UU, UU, BB, TT, NN, UU, FF, RR, UU, UU, // 0
134-
UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, UU, // 1
135-
__, __, QU, __, __, __, __, __, __, __, __, __, __, __, __, __, // 2
136-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 3
137-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 4
138-
__, __, __, __, __, __, __, __, __, __, __, __, BS, __, __, __, // 5
139-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 6
140-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 7
141-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 8
142-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // 9
143-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // A
144-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // B
145-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // C
146-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // D
147-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // E
148-
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, // F
149-
];
150-
151-
// Precomputed hex byte pairs for faster control character escaping
152-
pub(crate) const HEX_BYTES: [(u8, u8); 256] = {
153-
let mut bytes = [(0u8, 0u8); 256];
154-
let mut i = 0;
155-
while i < 256 {
156-
let high = (i >> 4) as u8;
157-
let low = (i & 0xF) as u8;
158-
bytes[i] = (
159-
if high < 10 {
160-
b'0' + high
161-
} else {
162-
b'a' + high - 10
163-
},
164-
if low < 10 {
165-
b'0' + low
166-
} else {
167-
b'a' + low - 10
168-
},
169-
);
170-
i += 1;
171-
}
172-
bytes
173-
};
174-
175119
/// Main entry point for JSON string escaping with SIMD acceleration
176120
/// If the platform is supported, the SIMD path will be used. Otherwise, the generic fallback will be used.
177121
pub fn escape<S: AsRef<str>>(input: S) -> String {

0 commit comments

Comments
 (0)