Browse Source

Avoid allocations when running UpdateIsEffectivelyEnabled.

Dariusz Komosiński 6 years ago
parent
commit
7f33ffaf8b
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/Avalonia.Input/InputElement.cs

+ 6 - 2
src/Avalonia.Input/InputElement.cs

@@ -565,9 +565,13 @@ namespace Avalonia.Input
         {
             IsEffectivelyEnabled = IsEnabledCore && (parent?.IsEffectivelyEnabled ?? true);
 
-            foreach (var child in this.GetVisualChildren().OfType<InputElement>())
+            var children = VisualChildren;
+
+            for (int i = 0; i < children.Count; ++i)
             {
-                child.UpdateIsEffectivelyEnabled(this);
+                var child = children[i] as InputElement;
+
+                child?.UpdateIsEffectivelyEnabled(this);
             }
         }
     }