From 4578ab3ed04169dcfeb5152c10202d0b8c4175e7 Mon Sep 17 00:00:00 2001 From: Max Wipfli Date: Thu, 8 Jul 2021 13:49:03 +0200 Subject: 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. --- Userland/Libraries/LibGfx/BitmapFont.cpp | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'Userland/Libraries') 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 -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) -- cgit v1.2.3