File tree Expand file tree Collapse file tree 2 files changed +2
-7
lines changed Expand file tree Collapse file tree 2 files changed +2
-7
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ const FIXTURE: &str = include_str!("../cal.com.tsx");
9
9
fn criterion_benchmark ( c : & mut Criterion ) {
10
10
c. bench_function ( "escape simd" , |b| b. iter ( || black_box ( encode_str ( FIXTURE ) ) ) ) ;
11
11
c. bench_function ( "escape v_jsonescape" , |b| {
12
- b. iter ( || black_box ( v_jsonescape:: escape ( FIXTURE ) ) )
12
+ b. iter ( || black_box ( v_jsonescape:: escape ( FIXTURE ) . to_string ( ) ) )
13
13
} ) ;
14
14
c. bench_function ( "escape software" , |b| {
15
15
b. iter ( || black_box ( encode_str_fallback ( FIXTURE ) ) )
Original file line number Diff line number Diff line change @@ -8,16 +8,13 @@ mod avx2;
8
8
9
9
#[ cfg( target_arch = "x86_64" ) ]
10
10
mod x86_64 {
11
- use super :: * ;
12
-
13
11
#[ inline]
14
12
pub fn encode_str < S : AsRef < str > > ( input : S ) -> String {
15
13
// Runtime CPU feature detection for AVX2
16
14
#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
17
15
{
18
16
if is_x86_feature_detected ! ( "avx2" ) {
19
- // Safe to use AVX2 implementation
20
- unsafe { return crate :: avx2:: encode_str ( input) }
17
+ return crate :: avx2:: encode_str ( input) ;
21
18
}
22
19
}
23
20
@@ -82,7 +79,6 @@ pub(crate) const HEX_BYTES: [(u8, u8); 256] = {
82
79
bytes
83
80
} ;
84
81
85
-
86
82
#[ macro_export]
87
83
// We only use our own error type; no need for From conversions provided by the
88
84
// standard library's try! macro. This reduces lines of LLVM IR by 4%.
@@ -160,7 +156,6 @@ pub fn encode_str<S: AsRef<str>>(input: S) -> String {
160
156
encode_str_fallback ( input)
161
157
}
162
158
163
-
164
159
#[ test]
165
160
fn test_escape_ascii_json_string ( ) {
166
161
let fixture = r#"abcdefghijklmnopqrstuvwxyz .*? hello world escape json string"# ;
You can’t perform that action at this time.
0 commit comments