From 631c8573013f7766444ee3674efb840842f78112 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Tue, 17 Jun 2025 12:33:49 +0200 Subject: [PATCH] LibGfx: Only determine glyphs info once in TextLayout We were calling into `hb_buffer_get_glyph_infos()` twice and setting up an unused `Vector`. --- Libraries/LibGfx/TextLayout.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Libraries/LibGfx/TextLayout.cpp b/Libraries/LibGfx/TextLayout.cpp index 836825b2bc7..ea87dbfe23e 100644 --- a/Libraries/LibGfx/TextLayout.cpp +++ b/Libraries/LibGfx/TextLayout.cpp @@ -59,10 +59,6 @@ NonnullRefPtr shape_text(FloatPoint baseline_start, float letter_spaci hb_buffer_add_utf8(buffer, reinterpret_cast(string.bytes()), string.byte_length(), 0, -1); hb_buffer_guess_segment_properties(buffer); - u32 glyph_count; - auto* glyph_info = hb_buffer_get_glyph_infos(buffer, &glyph_count); - Vector const input_glyph_info({ glyph_info, glyph_count }); - auto* hb_font = font.harfbuzz_font(); hb_feature_t const* hb_features_data = nullptr; Vector hb_features; @@ -81,8 +77,9 @@ NonnullRefPtr shape_text(FloatPoint baseline_start, float letter_spaci hb_shape(hb_font, buffer, hb_features_data, features.size()); - glyph_info = hb_buffer_get_glyph_infos(buffer, &glyph_count); - auto* positions = hb_buffer_get_glyph_positions(buffer, &glyph_count); + u32 glyph_count; + auto const* glyph_info = hb_buffer_get_glyph_infos(buffer, &glyph_count); + auto const* positions = hb_buffer_get_glyph_positions(buffer, &glyph_count); Vector glyph_run; glyph_run.ensure_capacity(glyph_count);