forked from AuroraMiddleware/gtk
cssmatcher: Speed up common matching
first-child and last-child are the most common usages of the nth-child machinery, so special-casing them makes sense.
This commit is contained in:
parent
59a7739fce
commit
03312371da
@ -358,6 +358,18 @@ gtk_css_matcher_node_nth_child (GtkCssNode *node,
|
||||
{
|
||||
int pos, x;
|
||||
|
||||
/* special-case the common "first-child" and "last-child" */
|
||||
if (a == 0)
|
||||
{
|
||||
while (b > 0 && node != NULL)
|
||||
{
|
||||
b--;
|
||||
node = prev_node_func (node);
|
||||
}
|
||||
|
||||
return b == 0 && node == NULL;
|
||||
}
|
||||
|
||||
/* count nodes */
|
||||
for (pos = 0; node != NULL; pos++)
|
||||
node = prev_node_func (node);
|
||||
@ -366,9 +378,6 @@ gtk_css_matcher_node_nth_child (GtkCssNode *node,
|
||||
* and return TRUE if X is integer >= 0 */
|
||||
x = pos - b;
|
||||
|
||||
if (a == 0)
|
||||
return x == 0;
|
||||
|
||||
if (x % a)
|
||||
return FALSE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user