summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2008-01-08 20:52:44 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2008-01-08 20:52:44 +0000
commitc3e8fa757a02f2a99a2ec7dc9f3281eeb0554af7 (patch)
tree966775d84c31668454dfa4c7070a104e39fc9c9f
parent2c2d25dc8c81ec3c0e2eb8b4ff13a83eef4186f6 (diff)
downloadpango-c3e8fa757a02f2a99a2ec7dc9f3281eeb0554af7.tar.gz
Minor cleanup. Attributes are initialized with start/end_index to apply to
2008-01-08 Behdad Esfahbod <behdad@gnome.org> * pango/pango-layout.c (ensure_tab_width), (process_line), (pango_layout_get_effective_attributes), (pango_layout_check_lines): Minor cleanup. Attributes are initialized with start/end_index to apply to entire text now, no need to initialize them explicitly anymore. svn path=/trunk/; revision=2536
-rw-r--r--ChangeLog8
-rw-r--r--pango/pango-layout.c24
2 files changed, 16 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index eab572f6..2b45d865 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-08 Behdad Esfahbod <behdad@gnome.org>
+
+ * pango/pango-layout.c (ensure_tab_width), (process_line),
+ (pango_layout_get_effective_attributes),
+ (pango_layout_check_lines): Minor cleanup. Attributes are initialized
+ with start/end_index to apply to entire text now, no need to
+ initialize them explicitly anymore.
+
2007-12-29 Behdad Esfahbod <behdad@gnome.org>
Bug 506284 – docs typo for pango_coverage_unref
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index 55c8a1e1..dd1ce5bd 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -2684,7 +2684,6 @@ ensure_tab_width (PangoLayout *layout)
PangoAttrIterator *iter;
PangoFontDescription *font_desc = pango_font_description_copy_static (pango_context_get_font_description (layout->context));
PangoLanguage *language;
- int i;
layout_attrs = pango_layout_get_effective_attributes (layout);
iter = pango_attr_list_get_iterator (layout_attrs);
@@ -2694,16 +2693,11 @@ ensure_tab_width (PangoLayout *layout)
attr = pango_attr_font_desc_new (font_desc);
pango_font_description_free (font_desc);
-
- attr->start_index = 0;
- attr->end_index = 1;
pango_attr_list_insert_before (tmp_attrs, attr);
if (language)
{
attr = pango_attr_language_new (language);
- attr->start_index = 0;
- attr->end_index = 1;
pango_attr_list_insert_before (tmp_attrs, attr);
}
@@ -2711,7 +2705,10 @@ ensure_tab_width (PangoLayout *layout)
pango_attr_iterator_destroy (iter);
if (layout_attrs != layout->attrs)
- pango_attr_list_unref (layout_attrs);
+ {
+ pango_attr_list_unref (layout_attrs);
+ layout_attrs = NULL;
+ }
pango_attr_list_unref (tmp_attrs);
item = items->data;
@@ -2720,9 +2717,7 @@ ensure_tab_width (PangoLayout *layout)
pango_item_free (item);
g_list_free (items);
- layout->tab_width = 0;
- for (i=0; i < glyphs->num_glyphs; i++)
- layout->tab_width += glyphs->glyphs[i].geometry.width;
+ layout->tab_width = pango_glyph_string_get_width (glyphs);
pango_glyph_string_free (glyphs);
@@ -3308,7 +3303,7 @@ process_line (PangoLayout *layout,
gboolean have_break = FALSE; /* If we've seen a possible break yet */
int break_remaining_width = 0; /* Remaining width before adding run with break */
- int break_start_offset = 0; /* Start width before adding run with break */
+ int break_start_offset = 0; /* Start offset before adding run with break */
GSList *break_link = NULL; /* Link holding run before break */
gboolean wrapped = FALSE; /* If we had to wrap the line */
@@ -3466,9 +3461,6 @@ pango_layout_get_effective_attributes (PangoLayout *layout)
if (layout->font_desc)
{
PangoAttribute *attr = pango_attr_font_desc_new (layout->font_desc);
- attr->start_index = 0;
- attr->end_index = layout->length;
-
pango_attr_list_insert_before (attrs, attr);
}
@@ -3544,7 +3536,7 @@ pango_layout_check_lines (PangoLayout *layout)
PangoAttrIterator *iter;
PangoDirection prev_base_dir = PANGO_DIRECTION_NEUTRAL, base_dir = PANGO_DIRECTION_NEUTRAL;
- if (layout->lines)
+ if (G_LIKELY (layout->lines))
return;
g_assert (!layout->log_attrs);
@@ -3552,7 +3544,7 @@ pango_layout_check_lines (PangoLayout *layout)
/* For simplicity, we make sure at this point that layout->text
* is non-NULL even if it is zero length
*/
- if (!layout->text)
+ if (G_UNLIKELY (!layout->text))
pango_layout_set_text (layout, NULL, 0);
attrs = pango_layout_get_effective_attributes (layout);