@@ -116,62 +116,6 @@ mod x86;
116
116
117
117
pub use generic:: escape_generic;
118
118
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
-
175
119
/// Main entry point for JSON string escaping with SIMD acceleration
176
120
/// If the platform is supported, the SIMD path will be used. Otherwise, the generic fallback will be used.
177
121
pub fn escape < S : AsRef < str > > ( input : S ) -> String {
0 commit comments