Add ASCII fast-path for char::is_grapheme_extended

I discovered that `impl Debug for str` is quite slow because it ends up doing a `unicode_data::grapheme_extend::lookup` for each char, which ends up doing a binary search.

This introduces a fast-path for ASCII chars which do not have this property.

The `lookup` is thus completely gone from profiles.
This commit is contained in:
Arpad Borsos 2024-02-15 12:00:34 +01:00
parent bd6b336133
commit 8eaaa6e610
No known key found for this signature in database
GPG Key ID: 570F20163159CB55

View File

@ -927,7 +927,7 @@ impl char {
#[must_use]
#[inline]
pub(crate) fn is_grapheme_extended(self) -> bool {
unicode::Grapheme_Extend(self)
self > '\x7f' && unicode::Grapheme_Extend(self)
}
/// Returns `true` if this `char` has one of the general categories for numbers.