diff options
author | Timm Bäder <mail@baedert.org> | 2020-04-14 17:43:35 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2020-06-08 19:15:29 +0200 |
commit | 03774a47fda0231fae38f44e68e05deaf9ca95dc (patch) | |
tree | 9203c90dcd10414ae326c30f9d1b63f6a5f33cfc | |
parent | 993ac0ad925e8a22e41591390d069d7ecf37518b (diff) | |
download | pango-03774a47fda0231fae38f44e68e05deaf9ca95dc.tar.gz |
layout: Try to avoid some work when creating iters
Instead of getting the logical rect and then not using it, try not to
compute it in the first place.
-rw-r--r-- | pango/pango-layout.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 872ccd71..ee754835 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -6183,7 +6183,6 @@ _pango_layout_get_iter (PangoLayout *layout, PangoLayoutIter*iter) { int run_start_index; - PangoRectangle logical_rect; g_return_if_fail (PANGO_IS_LAYOUT (layout)); @@ -6207,11 +6206,25 @@ _pango_layout_get_iter (PangoLayout *layout, iter->run = NULL; iter->line_extents = NULL; - pango_layout_get_extents_internal (layout, - NULL, - &logical_rect, - &iter->line_extents); - iter->layout_width = layout->width == -1 ? logical_rect.width : layout->width; + + if (layout->width == -1) + { + PangoRectangle logical_rect; + + pango_layout_get_extents_internal (layout, + NULL, + &logical_rect, + &iter->line_extents); + iter->layout_width = logical_rect.width; + } + else + { + pango_layout_get_extents_internal (layout, + NULL, + NULL, + &iter->line_extents); + iter->layout_width = layout->width; + } iter->line_index = 0; update_run (iter, run_start_index); |