Skip to content

Commit

Permalink
use HashSet and reduce casting
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Jan 18, 2024
1 parent 8821d48 commit 7f6c5af
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Controls/src/Core/View/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,22 @@ void RemoveItems(IEnumerable<IElementDefinition> elements)
List<IElementDefinition> remove = new List<IElementDefinition>();
List<IElementDefinition> add = new List<IElementDefinition>();
foreach (IElementDefinition item in _gestureRecognizers.OfType<IElementDefinition>())
var gestureRecognizers = _gestureRecognizers.OfType<IElementDefinition>().ToHashSet();
var compositeGestureRecognizers = GestureController.CompositeGestureRecognizers.OfType<IElementDefinition>().ToList();
foreach (IElementDefinition item in gestureRecognizers)
{
if (!_gestureRecognizers.Contains((IGestureRecognizer)item))
if (!gestureRecognizers.Contains(item))
add.Add(item);
item.Parent = this;
}
foreach (IElementDefinition item in GestureController.CompositeGestureRecognizers.OfType<IElementDefinition>())
foreach (IElementDefinition item in compositeGestureRecognizers)
{
if (item == _recognizerForPointerOverState)
continue;
if (_gestureRecognizers.Contains((IGestureRecognizer)item))
if (gestureRecognizers.Contains(item))
item.Parent = this;
else
remove.Add(item);
Expand Down

0 comments on commit 7f6c5af

Please sign in to comment.