UI: Minor optimization to Outliner lookup for hovered element
The lookup to find the hovered Outliner tree element would possibly check children that can be skipped with a simple check. I experimented with various ways to avoid work in this lookup. This one is simple and reliable, which others wouldn't have been afaics. Plus, there's not much performance to be gained here anyway.
This commit is contained in:
parent
15083d9e1e
commit
254f164b27
|
@ -84,12 +84,24 @@ TreeElement *outliner_find_item_at_y(const SpaceOutliner *soops,
|
|||
/* co_y is inside this element */
|
||||
return te_iter;
|
||||
}
|
||||
else if (TSELEM_OPEN(te_iter->store_elem, soops)) {
|
||||
/* co_y is lower than current element, possibly inside children */
|
||||
TreeElement *te_sub = outliner_find_item_at_y(soops, &te_iter->subtree, view_co_y);
|
||||
if (te_sub) {
|
||||
return te_sub;
|
||||
}
|
||||
|
||||
if (BLI_listbase_is_empty(&te_iter->subtree) || !TSELEM_OPEN(TREESTORE(te_iter), soops)) {
|
||||
/* No need for recursion. */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the coordinate is lower than the next element, we can continue with that one and skip
|
||||
* recursion too. */
|
||||
const TreeElement *te_next = te_iter->next;
|
||||
if (te_next && (view_co_y < (te_next->ys + UI_UNIT_Y))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* co_y is lower than current element (but not lower than the next one), possibly inside
|
||||
* children */
|
||||
TreeElement *te_sub = outliner_find_item_at_y(soops, &te_iter->subtree, view_co_y);
|
||||
if (te_sub) {
|
||||
return te_sub;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue