diff options
author | Timm Bäder <mail@baedert.org> | 2020-04-29 10:46:53 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2020-05-05 08:20:10 +0200 |
commit | cdb4d7112593191611d0666c3da82ee2d036b9e0 (patch) | |
tree | 74a21c17eff70954cc59941e6a5bbd7d16bfa216 /gtk/gtkcssselector.c | |
parent | 8b4d84981e4de19a1ee30a4c61b4cbb442c821fc (diff) | |
download | gtk+-cdb4d7112593191611d0666c3da82ee2d036b9e0.tar.gz |
cssprovider: Pass a GtkArray around when matching
We just use the resulting GPtrArray to set the values on a GtkCssLookup
and it had mostly a size of 1, in extremes a size of 11.
Diffstat (limited to 'gtk/gtkcssselector.c')
-rw-r--r-- | gtk/gtkcssselector.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c index 5c1572e038..b5f348d268 100644 --- a/gtk/gtkcssselector.c +++ b/gtk/gtkcssselector.c @@ -152,21 +152,23 @@ gtk_css_selector_tree_get_matches (const GtkCssSelectorTree *tree) } static void -g_ptr_array_insert_sorted (GPtrArray *array, - gpointer data) +gtk_array_insert_sorted (GtkArray *array, + gpointer data) { - gint i; + guint i; for (i = 0; i < array->len; i++) { - if (data == array->pdata[i]) + gpointer elem = gtk_array_index (array, i); + + if (data == elem) return; - if (data < array->pdata[i]) + if (data < elem) break; } - g_ptr_array_insert (array, i, data); + gtk_array_insert (array, i, data); } static inline gboolean @@ -1875,7 +1877,7 @@ gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree, static void gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree, - GPtrArray **results) + GtkArray *results) { int i; gpointer *matches; @@ -1884,11 +1886,8 @@ gtk_css_selector_tree_found_match (const GtkCssSelectorTree *tree, if (!matches) return; - if (*results == NULL) - *results = g_ptr_array_sized_new (16); - for (i = 0; matches[i] != NULL; i++) - g_ptr_array_insert_sorted (*results, matches[i]); + gtk_array_insert_sorted (results, matches[i]); } static gboolean @@ -1896,7 +1895,7 @@ gtk_css_selector_tree_match (const GtkCssSelectorTree *tree, const GtkCountingBloomFilter *filter, gboolean match_filter, GtkCssNode *node, - GPtrArray **results) + GtkArray *results) { const GtkCssSelectorTree *prev; GtkCssNode *child; @@ -1929,22 +1928,20 @@ gtk_css_selector_tree_match (const GtkCssSelectorTree *tree, return TRUE; } -GPtrArray * +void _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree, const GtkCountingBloomFilter *filter, - GtkCssNode *node) + GtkCssNode *node, + GtkArray *out_tree_rules) { const GtkCssSelectorTree *iter; - GPtrArray *results = NULL; for (iter = tree; iter != NULL; iter = gtk_css_selector_tree_get_sibling (iter)) { - gtk_css_selector_tree_match (iter, filter, FALSE, node, &results); + gtk_css_selector_tree_match (iter, filter, FALSE, node, out_tree_rules); } - - return results; } gboolean |