From 67143bd846c2b39ce94779d7ab2b5bd48e58d1cd Mon Sep 17 00:00:00 2001 From: Chris Lord Date: Thu, 25 Nov 2010 15:11:42 +0000 Subject: [PATCH] text: Optimise get_preferred_height for single-line-mode Don't calculate an extra layout in clutter_text_get_preferred_height for single-line strings, when it's unnecessary. There's no need to set the width of a layout when in single-line mode, as wrapping will not happen. --- clutter/clutter-text.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 4f76289..e18d9f9 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1998,6 +1998,9 @@ clutter_text_get_preferred_height (ClutterActor *self, gint logical_height; gfloat layout_height; + if (priv->single_line_mode) + for_width = -1; + layout = clutter_text_create_layout (CLUTTER_TEXT (self), for_width, -1); @@ -2015,7 +2018,7 @@ clutter_text_get_preferred_height (ClutterActor *self, /* if we wrap and ellipsize then the minimum height is * going to be at least the size of the first line */ - if (priv->ellipsize && priv->wrap) + if ((priv->ellipsize && priv->wrap) && !priv->single_line_mode) { PangoLayoutLine *line; gfloat line_height; -- 2.7.4