From e0d3132d19715b4225878cc6129fe69049685b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 11 Dec 2022 20:41:47 +0100 Subject: [PATCH] Fix search container filtering too much As it turns out, 99915f9286d10b12b00479346c30005832ee8823 introduced a performance regression in `SearchContainer`. Due to borrowing from #5154 too much, the search logic was changed in order to hook into `InvalidateLayout()` to perform search, rather than just do it when a new internal child was added, as was the case previously. For the sake of completeness, let's review the possible causes for `InvalidateLayout()` firing with respect to filtering: - `AddInternal()`: Valid, as the new child needs to be examined against the current filter, and preserved by reverting to the old code. - `RemoveInternal()`: Mostly irrelevant, as long as the presence of the removed drawable in the container doesn't impact the filter state of any of its siblings. Let's not support that case for now. - `ClearInternal()`: Totally irrelevant, as anything that could be filtered is now gone. - `SetLayoutPosition()`: Hopefully irrelevant. - `UpdateChildrenLife()`: Not relevant. Nothing in `SearchContainer` considers lifetime explicitly. - `FlowContainer.childLayout` becoming invalid: The invalidation flags there are `RequiredParentSizeToFit | Presence`. Neither should be relevant for filtering, given the direction taken with `IConditionalFilterable`. - `Direction` and `Spacing`: 100% irrelevant. --- osu.Framework/Graphics/Containers/SearchContainer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Framework/Graphics/Containers/SearchContainer.cs b/osu.Framework/Graphics/Containers/SearchContainer.cs index 244f72ebfa..eb0313eea3 100644 --- a/osu.Framework/Graphics/Containers/SearchContainer.cs +++ b/osu.Framework/Graphics/Containers/SearchContainer.cs @@ -81,9 +81,9 @@ public string SearchTerm private readonly Cached filterValid = new Cached(); private readonly ICollection> canBeShownBindables = new List>(); - protected override void InvalidateLayout() + protected override void AddInternal(Drawable drawable) { - base.InvalidateLayout(); + base.AddInternal(drawable); filterValid.Invalidate(); }