From 392516cb9957f59b4b98edff1b1d5e3b661ccb76 Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Thu, 27 Jul 2023 09:16:13 -0700 Subject: [PATCH] [Impeller] trimmed 3 bytes off of each Glyph (flutter/engine#44054) While profiling Impeller I saw that we were allocating ~80MB/s of `GlyphPosition`s. This should shave off 13MB/s by making Glyphs 20 bytes instead of 24. Screenshot 2023-07-26 at 4 51 24 PM [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- engine/src/flutter/impeller/typographer/glyph.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/impeller/typographer/glyph.h b/engine/src/flutter/impeller/typographer/glyph.h index b036e415cc..d3797568fd 100644 --- a/engine/src/flutter/impeller/typographer/glyph.h +++ b/engine/src/flutter/impeller/typographer/glyph.h @@ -17,7 +17,7 @@ namespace impeller { /// @brief The glyph index in the typeface. /// struct Glyph { - enum class Type { + enum class Type : uint8_t { kPath, kBitmap, }; @@ -39,6 +39,10 @@ struct Glyph { : index(p_index), type(p_type), bounds(p_bounds) {} }; +// Many Glyph instances are instantiated, so care should be taken when +// increasing the size. +static_assert(sizeof(Glyph) == 20); + } // namespace impeller template <>