cssprovider: Don't lookup on empty css providers

This should not have a huge performance impact, but debugging is easier
if we don't lookup in empty css providers.
This commit is contained in:
Timm Bäder 2019-08-24 10:35:53 +02:00
parent 514e60c1bb
commit d8df197489
3 changed files with 11 additions and 0 deletions

View File

@ -527,6 +527,9 @@ gtk_css_style_provider_lookup (GtkStyleProvider *provider,
int i;
GPtrArray *tree_rules;
if (_gtk_css_selector_tree_is_empty (priv->tree))
return;
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, matcher);
if (tree_rules)
{

View File

@ -1885,6 +1885,12 @@ gtk_css_selector_tree_get_change (const GtkCssSelectorTree *tree,
return change;
}
gboolean
_gtk_css_selector_tree_is_empty (const GtkCssSelectorTree *tree)
{
return tree == NULL;
}
GtkCssChange
_gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher)

View File

@ -47,6 +47,8 @@ GtkCssChange _gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *
const GtkCssMatcher *matcher);
void _gtk_css_selector_tree_match_print (const GtkCssSelectorTree *tree,
GString *str);
gboolean _gtk_css_selector_tree_is_empty (const GtkCssSelectorTree *tree) G_GNUC_CONST;
GtkCssSelectorTreeBuilder *_gtk_css_selector_tree_builder_new (void);