Auto merge of #125609 - diondokter:opt-size-char-count, r=thomcc · model-checking/verify-rust-std@0ef7706 (original) (raw)
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -24,7 +24,7 @@ const UNROLL_INNER: usize = 4; | ||
24 | 24 | |
25 | 25 | #[inline] |
26 | 26 | pub(super) fn count_chars(s: &str) -> usize { |
27 | -if s.len() < USIZE_SIZE * UNROLL_INNER { | |
27 | +if cfg!(feature = "optimize_for_size") | | |
28 | 28 | // Avoid entering the optimized implementation for strings where the |
29 | 29 | // difference is not likely to matter, or where it might even be slower. |
30 | 30 | // That said, a ton of thought was not spent on the particular threshold |