From 3d32d464e9a83ca2a89700778ece28307f4d359e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 6 Jan 2009 20:52:03 +0000 Subject: [PATCH] [text] Use cached length when possible Since clutter_text_set_text() measures the length of the text each time, we should use the cached length instead of recomputing the text length each time. This should save us some time when dealing with long, multi-byte texts. --- clutter/clutter-text.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 0b8deb153..da74de1c6 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -1143,7 +1143,7 @@ clutter_text_real_move_left (ClutterText *self, gint pos = priv->position; gint len; - len = g_utf8_strlen (priv->text, -1); + len = priv->n_chars; if (pos != 0 && len !=0) { @@ -1169,7 +1169,7 @@ clutter_text_real_move_right (ClutterText *self, gint pos = priv->position; gint len; - len = g_utf8_strlen (priv->text, -1); + len = priv->n_chars; if (pos != -1 && len !=0) { @@ -3190,7 +3190,7 @@ clutter_text_set_cursor_position (ClutterText *self, priv = self->priv; - len = g_utf8_strlen (priv->text, -1); + len = priv->n_chars; if (position < 0 || position >= len) priv->position = -1; @@ -3335,7 +3335,7 @@ clutter_text_set_max_length (ClutterText *self, if (priv->max_length != max) { if (max < 0) - max = g_utf8_strlen (priv->text, -1); + max = priv->n_chars; priv->max_length = max; @@ -3528,7 +3528,7 @@ clutter_text_delete_chars (ClutterText *self, if (!priv->text) return; - len = g_utf8_strlen (priv->text, -1); + len = priv->n_chars; new = g_string_new (priv->text); if (priv->position == -1)