From d27e7e018045c2871cb18dc93910c335c756d41b Mon Sep 17 00:00:00 2001 From: Sergey Bugaev Date: Fri, 28 Jul 2023 18:37:09 +0300 Subject: [PATCH] label: Microoptimize width-for-height computation We told Pango to limit width to mid pixels, and it returned a layout size of text_width by text_height; text_width can be considerably smaller than mid. If the layout fits, we know that it fits at text_width, so set max to that. This lets us skip many iterations in a typical case. --- gtk/gtklabel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index f223bae0d3..b230c0b05f 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -1202,7 +1202,7 @@ my_pango_layout_get_width_for_height (PangoLayout *layout, else if (text_height > for_height) min = mid + 1; else - max = mid; + max = text_width; } return min * PANGO_SCALE;