[pango] Bypass line reordering if all runs have the same direction
- From: Kristian Rietveld <kristian src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango] Bypass line reordering if all runs have the same direction
- Date: Wed, 17 Jul 2013 08:28:42 +0000 (UTC)
commit fcd74a7e711cf19efe8c6932b463acf419bdb33b
Author: Kristian Rietveld <kris lanedo com>
Date: Wed Jun 12 19:32:03 2013 +0200
Bypass line reordering if all runs have the same direction
pango/pango-layout.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index b1f6346..f1eed22 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -4882,8 +4882,36 @@ static void
pango_layout_line_reorder (PangoLayoutLine *line)
{
GSList *logical_runs = line->runs;
- line->runs = reorder_runs_recurse (logical_runs, g_slist_length (logical_runs));
- g_slist_free (logical_runs);
+ GSList *tmp_list;
+ gboolean all_even, all_odd;
+ guint8 level_or = 0, level_and = 1;
+ int length = 0;
+
+ /* Check if all items are in the same direction, in that case, the
+ * line does not need modification and we can avoid the expensive
+ * reorder runs recurse procedure.
+ */
+ for (tmp_list = logical_runs; tmp_list != NULL; tmp_list = tmp_list->next)
+ {
+ PangoLayoutRun *run = tmp_list->data;
+
+ level_or |= run->item->analysis.level;
+ level_and &= run->item->analysis.level;
+
+ length++;
+ }
+
+ /* If none of the levels had the LSB set, all numbers were even. */
+ all_even = (level_or & 0x1) == 0;
+
+ /* If all of the levels had the LSB set, all numbers were odd. */
+ all_odd = (level_and & 0x1) == 1;
+
+ if (!all_even && !all_odd)
+ {
+ line->runs = reorder_runs_recurse (logical_runs, length);
+ g_slist_free (logical_runs);
+ }
}
static int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]