diff options
author | Max Wipfli <mail@maxwipfli.ch> | 2021-07-08 13:49:03 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-09 20:17:07 +0200 |
commit | 4578ab3ed04169dcfeb5152c10202d0b8c4175e7 (patch) | |
tree | b248318a65efd6c3e2dd5a2abbfa43ac9ecedf0b | |
parent | 2afa35deb8075ed297cab72cc242cef87e1385e9 (diff) | |
download | serenity-4578ab3ed04169dcfeb5152c10202d0b8c4175e7.zip |
LibGfx: ALWAYS_INLINE BitmapFont::unicode_view_width
This adds the ALWAYS_INLINE attribute to unicode_view_width. Also, it
cleans up the BitmapFont::view() code a little bit. This should help
performance of this hot code. Because the call to the width() methods is
a virtual dispatch, it doesn't help to inline the width() methods
themselves.
-rw-r--r-- | Userland/Libraries/LibGfx/BitmapFont.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp index 136fb293c5..c89a620577 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/BitmapFont.cpp @@ -248,14 +248,12 @@ int BitmapFont::glyph_or_emoji_width_for_variable_width_font(u32 code_point) con return emoji->size().width(); } -int BitmapFont::width(const StringView& string) const -{ - Utf8View utf8 { string }; - return width(utf8); -} +int BitmapFont::width(StringView const& view) const { return unicode_view_width(Utf8View(view)); } +int BitmapFont::width(Utf8View const& view) const { return unicode_view_width(view); } +int BitmapFont::width(Utf32View const& view) const { return unicode_view_width(view); } template<typename T> -int BitmapFont::unicode_view_width(T const& view) const +ALWAYS_INLINE int BitmapFont::unicode_view_width(T const& view) const { if (view.is_empty()) return 0; @@ -280,16 +278,6 @@ int BitmapFont::unicode_view_width(T const& view) const return longest_width; } -int BitmapFont::width(const Utf8View& utf8) const -{ - return unicode_view_width(utf8); -} - -int BitmapFont::width(const Utf32View& view) const -{ - return unicode_view_width(view); -} - void BitmapFont::set_type(FontTypes type) { if (type == m_type) |