From e3372335ec1628e1d6ef1a4fd63b11bb47f2e0e6 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 7 Dec 2013 15:08:21 +0000 Subject: Just match against universal string intern instead of checking strings length/data. --- src/select/hash.c | 17 ++++++++++------- src/select/hash.h | 3 ++- src/select/select.c | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src/select') diff --git a/src/select/hash.c b/src/select/hash.c index ee91fc2..79c324b 100644 --- a/src/select/hash.c +++ b/src/select/hash.c @@ -95,10 +95,9 @@ static css_error _iterate_universal( * \return true iff chain head doesn't fail to match element name */ static inline bool _chain_good_for_element_name(const css_selector *selector, - const css_qname *qname) + const css_qname *qname, const lwc_string *uni) { - if (lwc_string_length(selector->data.qname.name) != 1 || - lwc_string_data(selector->data.qname.name)[0] != '*') { + if (selector->data.qname.name != uni) { bool match; if (lwc_string_caseless_isequal( selector->data.qname.name, qname->name, @@ -486,7 +485,8 @@ css_error css__selector_hash_find_by_class(css_selector_hash *hash, req->node_bloom) && _chain_good_for_element_name( head->sel, - &(req->qname)) && + &(req->qname), + req->uni) && _rule_good_for_media( head->sel->rule, req->media)) { @@ -565,7 +565,8 @@ css_error css__selector_hash_find_by_id(css_selector_hash *hash, req->node_bloom) && _chain_good_for_element_name( head->sel, - &req->qname) && + &req->qname, + req->uni) && _rule_good_for_media( head->sel->rule, req->media)) { @@ -1018,7 +1019,8 @@ css_error _iterate_classes( req->node_bloom) && _chain_good_for_element_name( head->sel, - &(req->qname)) && + &(req->qname), + req->uni) && _rule_good_for_media( head->sel->rule, req->media)) { @@ -1078,7 +1080,8 @@ css_error _iterate_ids( req->node_bloom) && _chain_good_for_element_name( head->sel, - &req->qname) && + &req->qname, + req->uni) && _rule_good_for_media( head->sel->rule, req->media)) { diff --git a/src/select/hash.h b/src/select/hash.h index 2217cbd..f572048 100644 --- a/src/select/hash.h +++ b/src/select/hash.h @@ -20,9 +20,10 @@ struct css_selector; typedef struct css_selector_hash css_selector_hash; struct css_hash_selection_requirments { - css_qname qname; /* Element name, or universal '*' */ + css_qname qname; /* Element name, or universal "*" */ lwc_string *class; /* Name of class, or NULL */ lwc_string *id; /* Name of id, or NULL */ + lwc_string *uni; /* Universal element string "*" */ uint64_t media; /* Media type(s) we're selecting for */ const css_bloom *node_bloom; /* Node's bloom filter */ }; diff --git a/src/select/select.c b/src/select/select.c index cfafe32..c8567f8 100644 --- a/src/select/select.c +++ b/src/select/select.c @@ -1355,6 +1355,7 @@ css_error match_selectors_in_sheet(css_select_ctx *ctx, /* Set up general selector chain requirments */ req.media = state->media; req.node_bloom = state->bloom; + req.uni = ctx->universal; /* Find hash chain that applies to current node */ req.qname = state->element; -- cgit v1.2.3