Skip to content

Commit

Permalink
perf: Reduce allocations in ShouldMirrorVisual
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Mar 8, 2024
1 parent 14cca95 commit eb007ca
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Uno.UI/UI/Xaml/UIElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,20 @@ internal Matrix3x2 GetFlowDirectionTransform()

private bool ShouldMirrorVisual()
{
if (this is FrameworkElement fe && this.FindFirstParent<FrameworkElement>(includeCurrent: false) is FrameworkElement feParent)
if (this is not FrameworkElement fe)
{
if (fe is not PopupPanel && fe.FlowDirection != feParent.FlowDirection)
return false;
}

var parent = VisualTreeHelper.GetParent(this);
while (parent is not null)
{
if (parent is FrameworkElement feParent)
{
return true;
return feParent is not PopupPanel && fe.FlowDirection != feParent.FlowDirection;
}

parent = VisualTreeHelper.GetParent(parent);
}

return false;
Expand Down

0 comments on commit eb007ca

Please sign in to comment.