Skip to content

Reduce memory allocations in querySelector resolution #17821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions ext/dom/lexbor/lexbor/selectors-adapted/selectors.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,14 @@ lxb_selectors_find(lxb_selectors_t *selectors, const xmlNode *root,
const lxb_css_selector_list_t *list,
lxb_selectors_cb_f cb, void *ctx)
{
lxb_selectors_entry_t *entry;
lxb_selectors_entry_t entry = {0};
lxb_selectors_nested_t nested;

entry = lexbor_dobject_calloc(selectors->objs);

entry->combinator = LXB_CSS_SELECTOR_COMBINATOR_CLOSE;
entry->selector = list->last;
entry.combinator = LXB_CSS_SELECTOR_COMBINATOR_CLOSE;
entry.selector = list->last;

nested.parent = NULL;
nested.entry = entry;
nested.entry = &entry;
nested.cb = cb;
nested.ctx = ctx;

Expand All @@ -363,20 +361,19 @@ lxb_selectors_match_node(lxb_selectors_t *selectors, const xmlNode *node,
lxb_selectors_cb_f cb, void *ctx)
{
lxb_status_t status;
lxb_selectors_entry_t *entry;
lxb_selectors_nested_t nested;

if (!CMP_NODE_TYPE(node, XML_ELEMENT_NODE)) {
return LXB_STATUS_OK;
}

entry = lexbor_dobject_calloc(selectors->objs);
lxb_selectors_entry_t entry = {0};

entry->combinator = LXB_CSS_SELECTOR_COMBINATOR_CLOSE;
entry->selector = list->last;
entry.combinator = LXB_CSS_SELECTOR_COMBINATOR_CLOSE;
entry.selector = list->last;

nested.parent = NULL;
nested.entry = entry;
nested.entry = &entry;
nested.cb = cb;
nested.ctx = ctx;

Expand Down
Loading