Optimize TreeSearch::_filter_tree for performance
This commit is contained in:
parent
8d781da1a6
commit
e6e1addbcb
|
@ -68,10 +68,16 @@ void TreeSearch::_filter_tree(const String &p_search_mask) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeItem *first_counting_ancestor = cur_item;
|
TreeItem *first_counting_ancestor = cur_item;
|
||||||
|
bool parents_visible = true;
|
||||||
while (first_counting_ancestor && !number_matches.has(first_counting_ancestor)) {
|
while (first_counting_ancestor && !number_matches.has(first_counting_ancestor)) {
|
||||||
|
// Performance: we only need to check the first visible ancestor. This is already optimal because of the ordering in ordered_tree_items.
|
||||||
|
if (!first_counting_ancestor->is_visible()){
|
||||||
|
parents_visible = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
first_counting_ancestor = first_counting_ancestor->get_parent();
|
first_counting_ancestor = first_counting_ancestor->get_parent();
|
||||||
}
|
}
|
||||||
if (!first_counting_ancestor || !_vector_has_bsearch(matching_entries, first_counting_ancestor)) {
|
if (!parents_visible || !first_counting_ancestor || !_vector_has_bsearch(matching_entries, first_counting_ancestor)) {
|
||||||
cur_item->set_visible(false);
|
cur_item->set_visible(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue