mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00: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
Notes:
github-actions[bot]
2024-09-10 09:04:37 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/80e37db280f Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1357
2 changed files with 8 additions and 3 deletions
|
@ -116,9 +116,12 @@ void TypefaceSkia::populate_glyph_page(GlyphPage& glyph_page, size_t page_index)
|
|||
|
||||
String TypefaceSkia::family() const
|
||||
{
|
||||
if (!m_family.has_value()) {
|
||||
SkString family_name;
|
||||
impl().skia_typeface->getFamilyName(&family_name);
|
||||
return String::from_utf8_without_validation(ReadonlyBytes { family_name.c_str(), family_name.size() });
|
||||
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 a new issue