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.
This commit is contained in:
Chris Lord 2010-11-25 15:11:42 +00:00
parent e1b58d9407
commit 67143bd846

View File

@ -1998,6 +1998,9 @@ clutter_text_get_preferred_height (ClutterActor *self,
gint logical_height; gint logical_height;
gfloat layout_height; gfloat layout_height;
if (priv->single_line_mode)
for_width = -1;
layout = clutter_text_create_layout (CLUTTER_TEXT (self), layout = clutter_text_create_layout (CLUTTER_TEXT (self),
for_width, -1); for_width, -1);
@ -2015,7 +2018,7 @@ clutter_text_get_preferred_height (ClutterActor *self,
/* if we wrap and ellipsize then the minimum height is /* if we wrap and ellipsize then the minimum height is
* going to be at least the size of the first line * 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; PangoLayoutLine *line;
gfloat line_height; gfloat line_height;