cssmatcher: Inline node values into matcher

So we don't have to go through the matcher->node->decl every time
This commit is contained in:
Timm Bäder 2019-08-21 11:18:22 +02:00
parent 75a48aed0b
commit a75529f3c0
2 changed files with 40 additions and 4 deletions

View File

@ -237,21 +237,47 @@ gtk_css_matcher_node_get_previous (GtkCssMatcher *matcher,
static GtkStateFlags
gtk_css_matcher_node_get_state (const GtkCssMatcher *matcher)
{
return gtk_css_node_get_state (matcher->node.node);
return matcher->node.node_state;
}
static gboolean
gtk_css_matcher_node_has_name (const GtkCssMatcher *matcher,
/*interned*/ const char *name)
{
return gtk_css_node_get_name (matcher->node.node) == name;
return matcher->node.node_name == name;
}
static gboolean
gtk_css_matcher_node_has_class (const GtkCssMatcher *matcher,
GQuark class_name)
{
return gtk_css_node_has_class (matcher->node.node, class_name);
const GQuark *classes = matcher->node.classes;
switch (matcher->node.n_classes)
{
case 3:
if (classes[2] == class_name)
return TRUE;
G_GNUC_FALLTHROUGH;
case 2:
if (classes[1] == class_name)
return TRUE;
G_GNUC_FALLTHROUGH;
case 1:
if (classes[0] == class_name)
return TRUE;
G_GNUC_FALLTHROUGH;
case 0:
return FALSE;
default:
return gtk_css_node_has_class (matcher->node.node, class_name);
}
return FALSE;
}
static gboolean
@ -259,7 +285,7 @@ gtk_css_matcher_node_has_id (const GtkCssMatcher *matcher,
const char *id)
{
/* assume all callers pass an interned string */
return gtk_css_node_get_id (matcher->node.node) == id;
return matcher->node.node_id == id;
}
static gboolean
@ -325,6 +351,11 @@ _gtk_css_matcher_node_init (GtkCssMatcher *matcher,
{
matcher->node.klass = &GTK_CSS_MATCHER_NODE;
matcher->node.node = node;
matcher->node.node_state = gtk_css_node_get_state (node);
matcher->node.node_name = gtk_css_node_get_name (node);
matcher->node.node_id = gtk_css_node_get_id (node);
matcher->node.classes = gtk_css_node_declaration_get_classes (gtk_css_node_get_declaration (node),
&matcher->node.n_classes);
}
/* GTK_CSS_MATCHER_WIDGET_ANY */

View File

@ -60,6 +60,11 @@ struct _GtkCssMatcherWidgetPath {
struct _GtkCssMatcherNode {
const GtkCssMatcherClass *klass;
GtkCssNode *node;
GtkStateFlags node_state;
const char *node_name;
const char *node_id;
const GQuark *classes;
guint n_classes;
};
struct _GtkCssMatcherSuperset {