[pango/wip/baedert/for-master2: 15/17] pango-layout: Try to avoid allocating a new PangoAttrList
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/wip/baedert/for-master2: 15/17] pango-layout: Try to avoid allocating a new PangoAttrList
- Date: Mon, 8 Jun 2020 17:22:22 +0000 (UTC)
commit c1943bd42fb4390a133dce0e2ec80da7306ba79c
Author: Timm Bäder <mail baedert org>
Date: Fri Apr 17 19:57:26 2020 +0200
pango-layout: Try to avoid allocating a new PangoAttrList
pango/pango-layout.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 2de3f9eb..07a32664 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -4102,17 +4102,25 @@ pango_layout_get_effective_attributes (PangoLayout *layout)
if (layout->attrs)
attrs = pango_attr_list_copy (layout->attrs);
else
- attrs = pango_attr_list_new ();
+ attrs = NULL;
if (layout->font_desc)
{
PangoAttribute *attr = pango_attr_font_desc_new (layout->font_desc);
+
+ if (!attrs)
+ attrs = pango_attr_list_new ();
+
pango_attr_list_insert_before (attrs, attr);
}
if (layout->single_paragraph)
{
PangoAttribute *attr = pango_attr_show_new (PANGO_SHOW_LINE_BREAKS);
+
+ if (!attrs)
+ attrs = pango_attr_list_new ();
+
pango_attr_list_insert_before (attrs, attr);
}
@@ -4250,11 +4258,19 @@ pango_layout_check_lines (PangoLayout *layout)
pango_layout_set_text (layout, NULL, 0);
attrs = pango_layout_get_effective_attributes (layout);
+ if (attrs)
+ {
+ shape_attrs = pango_attr_list_filter (attrs, affects_break_or_shape, NULL);
+ itemize_attrs = pango_attr_list_filter (attrs, affects_itemization, NULL);
- shape_attrs = pango_attr_list_filter (attrs, affects_break_or_shape, NULL);
- itemize_attrs = pango_attr_list_filter (attrs, affects_itemization, NULL);
- if (itemize_attrs)
- _pango_attr_list_get_iterator (itemize_attrs, &iter);
+ if (itemize_attrs)
+ _pango_attr_list_get_iterator (itemize_attrs, &iter);
+ }
+ else
+ {
+ shape_attrs = NULL;
+ itemize_attrs = NULL;
+ }
layout->log_attrs = g_new (PangoLogAttr, layout->n_chars + 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]