mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
LibGfx: Cache the family name in TypefaceSkia
Instead of asking Skia for the family name every time we're called, just cache the string once and make subsequent calls fast. This knocks a 3.2% item off the profile entirely on https://tailwindcss.com (at least on macOS with the CoreText backend)
This commit is contained in:
parent
84ec690d90
commit
80e37db280
|
|
@ -116,9 +116,12 @@ void TypefaceSkia::populate_glyph_page(GlyphPage& glyph_page, size_t page_index)
|
|||
|
||||
String TypefaceSkia::family() const
|
||||
{
|
||||
SkString family_name;
|
||||
impl().skia_typeface->getFamilyName(&family_name);
|
||||
return String::from_utf8_without_validation(ReadonlyBytes { family_name.c_str(), family_name.size() });
|
||||
if (!m_family.has_value()) {
|
||||
SkString family_name;
|
||||
impl().skia_typeface->getFamilyName(&family_name);
|
||||
m_family = String::from_utf8_without_validation(ReadonlyBytes { family_name.c_str(), family_name.size() });
|
||||
}
|
||||
return m_family.value();
|
||||
}
|
||||
|
||||
u16 TypefaceSkia::weight() const
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ private:
|
|||
ReadonlyBytes m_buffer;
|
||||
unsigned m_ttc_index { 0 };
|
||||
|
||||
mutable Optional<String> m_family;
|
||||
|
||||
// This cache stores information per code point.
|
||||
// It's segmented into pages with data about 256 code points each.
|
||||
struct GlyphPage {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user