summaryrefslogtreecommitdiff
path: root/src/select/select.c
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2011-11-04 22:50:50 +0000
committerMichael Drake <tlsa@netsurf-browser.org>2011-11-04 22:50:50 +0000
commitdc00fb391c96b5ec3ad0bb70789465bca50f45ff (patch)
tree20cca7560e2217ce2adf8769d1f0d6c01b4cbd63 /src/select/select.c
parentdb12dd2c03e303eda101b3307bca272af017b646 (diff)
downloadlibcss-dc00fb391c96b5ec3ad0bb70789465bca50f45ff.tar.gz
libcss-dc00fb391c96b5ec3ad0bb70789465bca50f45ff.tar.bz2
Selection micro optimisation.
svn path=/trunk/libcss/; revision=13120
Diffstat (limited to 'src/select/select.c')
-rw-r--r--src/select/select.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/select/select.c b/src/select/select.c
index 1851f47..47aca20 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -1427,7 +1427,15 @@ css_error match_details(css_select_ctx *ctx, void *node,
css_error error;
css_pseudo_element pseudo = CSS_PSEUDO_ELEMENT_NONE;
- /* We match by default (if there are no details than the element
+ /* Skip the element selector detail, which is always first.
+ * (Named elements are handled by match_named_combinator, so the
+ * element selector detail always matches here.) */
+ if (detail->next)
+ detail++;
+ else
+ detail = NULL;
+
+ /* We match by default (if there are no details other than the element
* selector, then we must match) */
*match = true;
@@ -1437,26 +1445,20 @@ css_error match_details(css_select_ctx *ctx, void *node,
* simpler details come first (and thus the expensive match routines
* can be avoided unless absolutely necessary)? */
- do {
- /* Named elements are handled by match_named_combinator, so
- * the element selector detail always matches here. */
- if (detail->type != CSS_SELECTOR_ELEMENT) {
-
- error = match_detail(ctx, node, detail, state,
- match, &pseudo);
- if (error != CSS_OK)
- return error;
+ while (detail != NULL) {
+ error = match_detail(ctx, node, detail, state, match, &pseudo);
+ if (error != CSS_OK)
+ return error;
- /* Detail doesn't match, so reject selector chain */
- if (*match == false)
- return CSS_OK;
- }
+ /* Detail doesn't match, so reject selector chain */
+ if (*match == false)
+ return CSS_OK;
if (detail->next)
detail++;
else
detail = NULL;
- } while (detail != NULL);
+ }
/* Return the applicable pseudo element, if required */
if (pseudo_element != NULL)