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");
99fn criterion_benchmark ( c : & mut Criterion ) {
1010 c. bench_function ( "escape simd" , |b| b. iter ( || black_box ( encode_str ( FIXTURE ) ) ) ) ;
1111 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 ( ) ) )
1313 } ) ;
1414 c. bench_function ( "escape software" , |b| {
1515 b. iter ( || black_box ( encode_str_fallback ( FIXTURE ) ) )
Original file line number Diff line number Diff line change @@ -8,16 +8,13 @@ mod avx2;
88
99#[ cfg( target_arch = "x86_64" ) ]
1010mod x86_64 {
11- use super :: * ;
12-
1311 #[ inline]
1412 pub fn encode_str < S : AsRef < str > > ( input : S ) -> String {
1513 // Runtime CPU feature detection for AVX2
1614 #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
1715 {
1816 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) ;
2118 }
2219 }
2320
@@ -82,7 +79,6 @@ pub(crate) const HEX_BYTES: [(u8, u8); 256] = {
8279 bytes
8380} ;
8481
85-
8682#[ macro_export]
8783// We only use our own error type; no need for From conversions provided by the
8884// 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 {
160156 encode_str_fallback ( input)
161157}
162158
163-
164159#[ test]
165160fn test_escape_ascii_json_string ( ) {
166161 let fixture = r#"abcdefghijklmnopqrstuvwxyz .*? hello world escape json string"# ;
You can’t perform that action at this time.
0 commit comments