[pango/tab-speedup: 3/4] layout: Call pango_tab_array_sort




commit 169d411a5611be160e10334cceffd9ee300df3d1
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Dec 1 23:03:52 2021 -0500

    layout: Call pango_tab_array_sort
    
    We want to optimize access to tab stops,
    and will assume they are ordered.

 pango/pango-layout.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/pango/pango-layout.c b/pango/pango-layout.c
index fc8cc212..27755d67 100644
--- a/pango/pango-layout.c
+++ b/pango/pango-layout.c
@@ -1032,10 +1032,13 @@ pango_layout_set_tabs (PangoLayout   *layout,
 
   if (tabs != layout->tabs)
     {
-      if (layout->tabs)
-        pango_tab_array_free (layout->tabs);
+      g_clear_pointer (&layout->tabs, pango_tab_array_free);
 
-      layout->tabs = tabs ? pango_tab_array_copy (tabs) : NULL;
+      if (tabs)
+        {
+          layout->tabs = pango_tab_array_copy (tabs);
+          pango_tab_array_sort (layout->tabs);
+        }
 
       layout_changed (layout);
     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]