Skip to content

Commit a6ce7cf

Browse files
committed
use std::str::from_utf8() for inputs < 64 bytes
1 parent 0b44a36 commit a6ce7cf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/implementation/x86/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ pub(crate) unsafe fn validate_utf8_basic(
2424
(fun)(input)
2525
}
2626

27+
if input.len() < 64 {
28+
return super::validate_utf8_basic_fallback(input);
29+
}
30+
2731
let fun = FN.load(Ordering::Relaxed);
2832
mem::transmute::<FnRaw, super::ValidateUtf8Fn>(fun)(input)
2933
}
@@ -88,6 +92,10 @@ pub(crate) unsafe fn validate_utf8_compat(
8892
(fun)(input)
8993
}
9094

95+
if input.len() < 64 {
96+
return super::validate_utf8_compat_fallback(input);
97+
}
98+
9199
let fun = FN.load(Ordering::Relaxed);
92100
mem::transmute::<FnRaw, super::ValidateUtf8CompatFn>(fun)(input)
93101
}

0 commit comments

Comments
 (0)