mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
LibGfx: Optimize BitmapFont::unicode_view_width() a bit
This optimizes the method to no longer compare if width > longest_width on every iteration, since it's only required on CR/LF or at the end.
This commit is contained in:
parent
4578ab3ed0
commit
006e5998c5
Notes:
sideshowbarker
2024-07-18 09:58:53 +09:00
Author: https://github.com/MaxWipfli Commit: https://github.com/SerenityOS/serenity/commit/006e5998c51 Pull-request: https://github.com/SerenityOS/serenity/pull/8558 Reviewed-by: https://github.com/awesomekling
1 changed files with 2 additions and 3 deletions
|
@ -264,6 +264,7 @@ ALWAYS_INLINE int BitmapFont::unicode_view_width(T const& view) const
|
|||
for (u32 code_point : view) {
|
||||
if (code_point == '\n' || code_point == '\r') {
|
||||
first = true;
|
||||
longest_width = max(width, longest_width);
|
||||
width = 0;
|
||||
continue;
|
||||
}
|
||||
|
@ -271,10 +272,8 @@ ALWAYS_INLINE int BitmapFont::unicode_view_width(T const& view) const
|
|||
width += glyph_spacing();
|
||||
first = false;
|
||||
width += glyph_or_emoji_width(code_point);
|
||||
if (width > longest_width)
|
||||
longest_width = width;
|
||||
}
|
||||
|
||||
longest_width = max(width, longest_width);
|
||||
return longest_width;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue