[pango/wip/baedert/for-master: 44/53] attrlist: Remove attributes_tail
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/wip/baedert/for-master: 44/53] attrlist: Remove attributes_tail
- Date: Wed, 10 Jun 2020 04:12:40 +0000 (UTC)
commit 648bdfad516bd1413800f81c32d63450db4c27e0
Author: Timm Bäder <mail baedert org>
Date: Fri Apr 17 14:15:53 2020 +0200
attrlist: Remove attributes_tail
It's only very rarely used, and will become even less important later.
pango/pango-attributes-private.h | 1 -
pango/pango-attributes.c | 35 +++++++++++------------------------
2 files changed, 11 insertions(+), 25 deletions(-)
---
diff --git a/pango/pango-attributes-private.h b/pango/pango-attributes-private.h
index 230feb3d..bf5bdade 100644
--- a/pango/pango-attributes-private.h
+++ b/pango/pango-attributes-private.h
@@ -32,7 +32,6 @@ struct _PangoAttrList
{
guint ref_count;
GSList *attributes;
- GSList *attributes_tail;
};
void _pango_attr_list_init (PangoAttrList *list);
diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c
index 44b553fc..c858638a 100644
--- a/pango/pango-attributes.c
+++ b/pango/pango-attributes.c
@@ -1311,7 +1311,6 @@ _pango_attr_list_init (PangoAttrList *list)
{
list->ref_count = 1;
list->attributes = NULL;
- list->attributes_tail = NULL;
}
/**
@@ -1427,7 +1426,6 @@ pango_attr_list_copy (PangoAttrList *list)
}
/* we're going to reverse the nodes, so head becomes tail */
- new->attributes_tail = new_attrs;
new->attributes = g_slist_reverse (new_attrs);
return new;
@@ -1439,19 +1437,21 @@ pango_attr_list_insert_internal (PangoAttrList *list,
gboolean before)
{
GSList *tmp_list, *prev, *link;
- guint start_index = attr->start_index;
+ const guint start_index = attr->start_index;
+ PangoAttribute *last_attr;
if (!list->attributes)
{
list->attributes = g_slist_prepend (NULL, attr);
- list->attributes_tail = list->attributes;
+ return;
}
- else if (((PangoAttribute *)list->attributes_tail->data)->start_index < start_index ||
- (!before && ((PangoAttribute *)list->attributes_tail->data)->start_index == start_index))
+
+ last_attr = g_slist_last (list->attributes)->data;
+
+ if (last_attr->start_index < start_index ||
+ (!before && last_attr->start_index == start_index))
{
- list->attributes_tail = g_slist_append (list->attributes_tail, attr);
- list->attributes_tail = list->attributes_tail->next;
- g_assert (list->attributes_tail);
+ list->attributes = g_slist_append (list->attributes, attr);
}
else
{
@@ -1574,9 +1574,6 @@ pango_attr_list_change (PangoAttrList *list,
else
list->attributes = link;
- if (!tmp_list)
- list->attributes_tail = link;
-
prev = link;
tmp_list = prev->next;
break;
@@ -1668,9 +1665,6 @@ pango_attr_list_change (PangoAttrList *list,
pango_attribute_destroy (tmp_attr);
prev->next = tmp_list->next;
- if (!prev->next)
- list->attributes_tail = prev;
-
g_slist_free_1 (tmp_list);
tmp_list = prev->next;
@@ -1713,9 +1707,6 @@ pango_attr_list_change (PangoAttrList *list,
prev2->next = tmp_list;
tmp_list->next = tmp_list2;
- if (!tmp_list->next)
- list->attributes_tail = tmp_list;
-
tmp_list = old_next;
continue;
@@ -2410,9 +2401,6 @@ pango_attr_list_filter (PangoAttrList *list,
if ((*func) (tmp_attr, data))
{
- if (!tmp_list->next)
- list->attributes_tail = prev;
-
if (prev)
prev->next = tmp_list->next;
else
@@ -2423,12 +2411,11 @@ pango_attr_list_filter (PangoAttrList *list,
if (!new)
{
new = pango_attr_list_new ();
- new->attributes = new->attributes_tail = tmp_list;
+ new->attributes = tmp_list;
}
else
{
- new->attributes_tail->next = tmp_list;
- new->attributes_tail = tmp_list;
+ g_slist_last (new->attributes)->next = tmp_list;
}
goto next_attr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]