Skip to content

Commit ff00559

Browse files
committed
Only use non-chunked UTF8 validation on optimize_for_size
1 parent bc57db5 commit ff00559

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

library/core/src/str/validations.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,14 @@ const unsafe fn run_with_error_handling(
263263

264264
/// Walks through `v` checking that it's a valid UTF-8 sequence,
265265
/// returning `Ok(())` in that case, or, if it is invalid, `Err(err)`.
266-
#[inline]
266+
#[cfg_attr(not(feature = "optimize_for_size"), inline)]
267267
#[rustc_allow_const_fn_unstable(const_eval_select)] // fallback impl has same behavior
268268
pub(super) const fn run_utf8_validation(bytes: &[u8]) -> Result<(), Utf8Error> {
269-
const_eval_select((bytes,), run_utf8_validation_const, run_utf8_validation_rt)
269+
if cfg!(feature = "optimize_for_size") {
270+
run_utf8_validation_const(bytes)
271+
} else {
272+
const_eval_select((bytes,), run_utf8_validation_const, run_utf8_validation_rt)
273+
}
270274
}
271275

272276
#[inline]

0 commit comments

Comments
 (0)