Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-06-19 20:21:39 +0300
committerJulian Eisel <julian@blender.org>2020-06-19 21:06:37 +0300
commit254f164b27a416177e3bf47bd81498a2da929e43 (patch)
tree789ca9f2a3bf1f419df37694dd0c9c8fcc85f31a /source/blender/editors/space_outliner
parent15083d9e1eebe0be0cca427602aa826f113ff997 (diff)
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.
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner_utils.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/source/blender/editors/space_outliner/outliner_utils.c b/source/blender/editors/space_outliner/outliner_utils.c
index 5f19d8b8757..a120718e36b 100644
--- a/source/blender/editors/space_outliner/outliner_utils.c
+++ b/source/blender/editors/space_outliner/outliner_utils.c
@@ -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;
}
}
}