diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-02-22 15:07:50 -0500 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-02-22 21:11:48 +0100 |
commit | f33ead7f5f19307f322d432f72aea5674044bf23 (patch) | |
tree | d80c609745ef8a5ed2cdab4dbfb0c9a2b05e89ee /Userland/Libraries/LibGfx/Font | |
parent | fdf090a2996e7e8bb0a6c69de5d221de230edbfc (diff) | |
download | serenity-f33ead7f5f19307f322d432f72aea5674044bf23.zip |
LibGfx: Bail early from Emoji::emoji_for_code_point_iterator for ASCII
On a profile of scrolling around on the welcome page in the Browser,
this drops the runtime percentage of Font::glyph_or_emoji_width from
about 70% to 0.8%.
Diffstat (limited to 'Userland/Libraries/LibGfx/Font')
-rw-r--r-- | Userland/Libraries/LibGfx/Font/Emoji.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Font/Emoji.cpp b/Userland/Libraries/LibGfx/Font/Emoji.cpp index 17aa9bcd15..de63da0567 100644 --- a/Userland/Libraries/LibGfx/Font/Emoji.cpp +++ b/Userland/Libraries/LibGfx/Font/Emoji.cpp @@ -5,6 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ +#include <AK/CharacterTypes.h> #include <AK/DeprecatedString.h> #include <AK/HashMap.h> #include <AK/Span.h> @@ -52,6 +53,8 @@ static Bitmap const* emoji_for_code_point_iterator_impl(CodePointIterator& it) // into a certain range in the loop below (emojis, modifiers, variation selectors, ZWJ), // and bailing out early if not. Current worst case is 10 file lookups for any sequence of // code points (if the first glyph isn't part of the font in regular text rendering). + if (is_ascii(*it)) + return nullptr; constexpr size_t max_emoji_code_point_sequence_length = 10; |