diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-12-02 19:51:15 +0000 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-12-02 19:51:15 +0000 |
commit | 50d630321da94186fe46590574b79c1d7f631605 (patch) | |
tree | 0d4cafbc5fe0732ce2a8a24497f112ba269f0a4c /pango/pango-tabs.c | |
parent | f84af25aefefa335a7e8ae8080ffa9f74a782cf3 (diff) | |
parent | 37f6f3639e802872aaf47cea44f07e9cc672022c (diff) | |
download | pango-50d630321da94186fe46590574b79c1d7f631605.tar.gz |
Merge branch 'tab-speedup' into 'main'
Add pango_tab_array_sort
See merge request GNOME/pango!530
Diffstat (limited to 'pango/pango-tabs.c')
-rw-r--r-- | pango/pango-tabs.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/pango/pango-tabs.c b/pango/pango-tabs.c index 27ae3be8..0665161c 100644 --- a/pango/pango-tabs.c +++ b/pango/pango-tabs.c @@ -576,3 +576,28 @@ pango_tab_array_get_decimal_point (PangoTabArray *tab_array, return tab_array->tabs[tab_index].decimal_point; } + +static int +compare_tabs (const void *p1, const void *p2) +{ + const PangoTab *t1 = p1; + const PangoTab *t2 = p2; + + return t1->location - t2->location; +} + +/** + * pango_tab_array_sort: + * @tab_array: a `PangoTabArray` + * + * Utility function to ensure that the tab stops are in increasing order. + * + * Since: 1.50 + */ +void +pango_tab_array_sort (PangoTabArray *tab_array) +{ + g_return_if_fail (tab_array != NULL); + + qsort (tab_array->tabs, tab_array->size, sizeof (PangoTab), compare_tabs); +} |