forked from AuroraMiddleware/gtk
Optimize gtk_css_node_declaration_has_class
This function is getting called a lot. Statistics for the gtk3-demo listbox example show most calls with 0-4 classes. Unrolling the cases a bit brings the instruction count in callgrind from 93M to 52M.
This commit is contained in:
parent
59797754b4
commit
cf0e087527
@ -311,7 +311,28 @@ gboolean
|
||||
gtk_css_node_declaration_has_class (const GtkCssNodeDeclaration *decl,
|
||||
GQuark class_quark)
|
||||
{
|
||||
return find_class (decl, class_quark, NULL);
|
||||
GQuark *classes = get_classes (decl);
|
||||
|
||||
switch (decl->n_classes)
|
||||
{
|
||||
case 3:
|
||||
if (classes[2] == class_quark)
|
||||
return TRUE;
|
||||
|
||||
case 2:
|
||||
if (classes[1] == class_quark)
|
||||
return TRUE;
|
||||
|
||||
case 1:
|
||||
if (classes[0] == class_quark)
|
||||
return TRUE;
|
||||
|
||||
case 0:
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
return find_class (decl, class_quark, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
GList *
|
||||
|
Loading…
Reference in New Issue
Block a user