You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently functions like lxb_dom_elements_by_class_name iterates the whole dom using lxb_dom_node_simple_walk. In many cases this could be a suboptimal solution.
For example:
<divclass="a"></div><divclass="a"></div><divclass="a">test</div><divclass="a"></div>
... many more ...
If i need to find the first non-empty div, I could stop the search after the third result rather than read all the other.
This could be achived probably returning a range/iterator like this:
node=0;
while(true)
{
node=lxb_dom_elements_by_class_name_iterator(root, node, "a", 1);
if (node==0) break;
else {
// I do my check on node// if (the_div_is_not_empty) break;
}
}
In this way:
Collection is not needed
No extra allocation for collections!
I browse only the nodes I need
I can implement many function (limit, skip, restarting a search and so on)
I can mixing iterator together (f.e. coupling two interator in the same while-loop)
Currently functions like
lxb_dom_elements_by_class_name
iterates the whole dom usinglxb_dom_node_simple_walk
. In many cases this could be a suboptimal solution.For example:
If i need to find the first non-empty div, I could stop the search after the third result rather than read all the other.
This could be achived probably returning a range/iterator like this:
or something similar.
Of course this can be easily converted to a plain array looping thru it.
The text was updated successfully, but these errors were encountered: