Skip to content

Commit 91039ea

Browse files
committed
Optimizations
1 parent 7c1365f commit 91039ea

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

ext/dom/lexbor/lexbor/selectors-adapted/selectors.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ static zend_always_inline bool lxb_selectors_adapted_cmp_ns(const xmlNode *a, co
4040

4141
static zend_always_inline bool lxb_selectors_adapted_cmp_local_name_id(const xmlNode *node, const lxb_selectors_adapted_id *id)
4242
{
43-
return node->name == id->name || strcmp((const char *) node->name, (const char *) id->name) == 0;
43+
uintptr_t ptr = (uintptr_t) node->name;
44+
if ((ptr & (ZEND_MM_ALIGNMENT - 1)) != 0) {
45+
/* It cannot be a heap-allocated string because the pointer is not properly aligned for a heap allocation.
46+
* Therefore, it must be interned into the dictionary pool. */
47+
return node->name == id->name;
48+
}
49+
50+
return strcmp((const char *) node->name, (const char *) id->name) == 0;
4451
}
4552

4653
static zend_always_inline const xmlAttr *lxb_selectors_adapted_attr(const xmlNode *node, const lxb_char_t *name)
@@ -1194,8 +1201,7 @@ lxb_selectors_match(lxb_selectors_t *selectors, lxb_selectors_entry_t *entry,
11941201
case LXB_CSS_SELECTOR_TYPE_PSEUDO_ELEMENT_FUNCTION:
11951202
return false;
11961203

1197-
default:
1198-
break;
1204+
EMPTY_SWITCH_DEFAULT_CASE();
11991205
}
12001206

12011207
return false;
@@ -1398,8 +1404,7 @@ lxb_selectors_match_attribute(const lxb_css_selector_t *selector,
13981404

13991405
return lexbor_str_data_ncmp_contain(trg.data, trg.length,
14001406
src->data, src->length);
1401-
default:
1402-
break;
1407+
EMPTY_SWITCH_DEFAULT_CASE();
14031408
}
14041409

14051410
return false;

0 commit comments

Comments
 (0)