forked from AuroraMiddleware/gtk
Manipulate bits more efficiently
The function to translate GtkCssChange enum values to the PARENT ones is called very frequently. This patch speeds it up tremendously. The callgrind instruction count for this function in the listbox demo goes from 108M to 7M.
This commit is contained in:
parent
a9481cb410
commit
d7dd6eccd5
@ -70,28 +70,26 @@ _gtk_css_change_for_sibling (GtkCssChange match)
|
|||||||
GtkCssChange
|
GtkCssChange
|
||||||
_gtk_css_change_for_child (GtkCssChange match)
|
_gtk_css_change_for_child (GtkCssChange match)
|
||||||
{
|
{
|
||||||
static const GtkCssChangeTranslation table[] = {
|
#define BASE_STATES ( GTK_CSS_CHANGE_CLASS \
|
||||||
{ GTK_CSS_CHANGE_CLASS, GTK_CSS_CHANGE_PARENT_CLASS },
|
| GTK_CSS_CHANGE_NAME \
|
||||||
{ GTK_CSS_CHANGE_NAME, GTK_CSS_CHANGE_PARENT_NAME },
|
| GTK_CSS_CHANGE_ID \
|
||||||
{ GTK_CSS_CHANGE_ID, GTK_CSS_CHANGE_PARENT_ID },
|
| GTK_CSS_CHANGE_FIRST_CHILD \
|
||||||
{ GTK_CSS_CHANGE_FIRST_CHILD, GTK_CSS_CHANGE_PARENT_FIRST_CHILD },
|
| GTK_CSS_CHANGE_LAST_CHILD \
|
||||||
{ GTK_CSS_CHANGE_LAST_CHILD, GTK_CSS_CHANGE_PARENT_LAST_CHILD },
|
| GTK_CSS_CHANGE_NTH_CHILD \
|
||||||
{ GTK_CSS_CHANGE_NTH_CHILD, GTK_CSS_CHANGE_PARENT_NTH_CHILD },
|
| GTK_CSS_CHANGE_NTH_LAST_CHILD \
|
||||||
{ GTK_CSS_CHANGE_NTH_LAST_CHILD, GTK_CSS_CHANGE_PARENT_NTH_LAST_CHILD },
|
| GTK_CSS_CHANGE_STATE \
|
||||||
{ GTK_CSS_CHANGE_STATE, GTK_CSS_CHANGE_PARENT_STATE },
|
| GTK_CSS_CHANGE_SIBLING_CLASS \
|
||||||
{ GTK_CSS_CHANGE_SIBLING_CLASS, GTK_CSS_CHANGE_PARENT_SIBLING_CLASS },
|
| GTK_CSS_CHANGE_SIBLING_NAME \
|
||||||
{ GTK_CSS_CHANGE_SIBLING_NAME, GTK_CSS_CHANGE_PARENT_SIBLING_NAME },
|
| GTK_CSS_CHANGE_SIBLING_ID \
|
||||||
{ GTK_CSS_CHANGE_SIBLING_ID, GTK_CSS_CHANGE_PARENT_SIBLING_ID },
|
| GTK_CSS_CHANGE_SIBLING_FIRST_CHILD \
|
||||||
{ GTK_CSS_CHANGE_SIBLING_FIRST_CHILD, GTK_CSS_CHANGE_PARENT_SIBLING_FIRST_CHILD },
|
| GTK_CSS_CHANGE_SIBLING_LAST_CHILD \
|
||||||
{ GTK_CSS_CHANGE_SIBLING_LAST_CHILD, GTK_CSS_CHANGE_PARENT_SIBLING_LAST_CHILD },
|
| GTK_CSS_CHANGE_SIBLING_NTH_CHILD \
|
||||||
{ GTK_CSS_CHANGE_SIBLING_NTH_CHILD, GTK_CSS_CHANGE_PARENT_SIBLING_NTH_CHILD },
|
| GTK_CSS_CHANGE_SIBLING_NTH_LAST_CHILD \
|
||||||
{ GTK_CSS_CHANGE_SIBLING_NTH_LAST_CHILD, GTK_CSS_CHANGE_PARENT_SIBLING_NTH_LAST_CHILD },
|
| GTK_CSS_CHANGE_SIBLING_STATE )
|
||||||
{ GTK_CSS_CHANGE_SIBLING_STATE, GTK_CSS_CHANGE_PARENT_SIBLING_STATE },
|
|
||||||
{ GTK_CSS_CHANGE_SOURCE, 0 },
|
|
||||||
{ GTK_CSS_CHANGE_PARENT_STYLE, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
return gtk_css_change_translate (match, table, G_N_ELEMENTS (table));
|
#define PARENT_SHIFT 16
|
||||||
|
|
||||||
|
return (match & ~(BASE_STATES|GTK_CSS_CHANGE_SOURCE|GTK_CSS_CHANGE_PARENT_STYLE)) | ((match & BASE_STATES) << PARENT_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user