[gtk] label: Use pango_layout_get_log_attrs_readonly
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] label: Use pango_layout_get_log_attrs_readonly
- Date: Tue, 29 Jan 2019 06:25:17 +0000 (UTC)
commit d54cccfdd573e02c83cb584ffb7a58f4bc99a9a6
Author: Timm Bäder <mail baedert org>
Date: Sun Jan 20 09:22:55 2019 +0100
label: Use pango_layout_get_log_attrs_readonly
No need to memdup the log attrs in this case.
gtk/gtklabel.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 57db38485b..c9739e0911 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -5638,15 +5638,15 @@ gtk_label_move_logically (GtkLabel *label,
if (priv->text)
{
- PangoLogAttr *log_attrs;
+ const PangoLogAttr *log_attrs;
gint n_attrs;
gint length;
gtk_label_ensure_layout (label);
-
+
length = g_utf8_strlen (priv->text, -1);
- pango_layout_get_log_attrs (priv->layout, &log_attrs, &n_attrs);
+ log_attrs = pango_layout_get_log_attrs_readonly (priv->layout, &n_attrs);
while (count > 0 && offset < length)
{
@@ -5664,8 +5664,6 @@ gtk_label_move_logically (GtkLabel *label,
count++;
}
-
- g_free (log_attrs);
}
return g_utf8_offset_to_pointer (priv->text, offset) - priv->text;
@@ -5738,19 +5736,17 @@ gtk_label_move_forward_word (GtkLabel *label,
length = g_utf8_strlen (priv->text, -1);
if (new_pos < length)
{
- PangoLogAttr *log_attrs;
+ const PangoLogAttr *log_attrs;
gint n_attrs;
gtk_label_ensure_layout (label);
- pango_layout_get_log_attrs (priv->layout, &log_attrs, &n_attrs);
+ log_attrs = pango_layout_get_log_attrs_readonly (priv->layout, &n_attrs);
/* Find the next word end */
new_pos++;
while (new_pos < n_attrs && !log_attrs[new_pos].is_word_end)
- new_pos++;
-
- g_free (log_attrs);
+ new_pos++;
}
return g_utf8_offset_to_pointer (priv->text, new_pos) - priv->text;
@@ -5767,20 +5763,18 @@ gtk_label_move_backward_word (GtkLabel *label,
if (new_pos > 0)
{
- PangoLogAttr *log_attrs;
+ const PangoLogAttr *log_attrs;
gint n_attrs;
gtk_label_ensure_layout (label);
- pango_layout_get_log_attrs (priv->layout, &log_attrs, &n_attrs);
+ log_attrs = pango_layout_get_log_attrs_readonly (priv->layout, &n_attrs);
new_pos -= 1;
/* Find the previous word beginning */
while (new_pos > 0 && !log_attrs[new_pos].is_word_start)
- new_pos--;
-
- g_free (log_attrs);
+ new_pos--;
}
return g_utf8_offset_to_pointer (priv->text, new_pos) - priv->text;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]