1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:37:34 +00:00

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%.
This commit is contained in:
Timothy Flynn 2023-02-22 15:07:50 -05:00 committed by Andreas Kling
parent fdf090a299
commit f33ead7f5f

View file

@ -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;