Browse Source
Merge pull request #2964 from MarchingCube/alloc-effectivelyenabled
Avoid allocations when running UpdateIsEffectivelyEnabled.
pull/2970/head
danwalmsley
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
10 additions and
2 deletions
-
src/Avalonia.Input/InputElement.cs
|
|
|
@ -565,9 +565,17 @@ namespace Avalonia.Input |
|
|
|
{ |
|
|
|
IsEffectivelyEnabled = IsEnabledCore && (parent?.IsEffectivelyEnabled ?? true); |
|
|
|
|
|
|
|
foreach (var child in this.GetVisualChildren().OfType<InputElement>()) |
|
|
|
// PERF-SENSITIVE: This is called on entire hierarchy and using foreach or LINQ
|
|
|
|
// will cause extra allocations and overhead.
|
|
|
|
|
|
|
|
var children = VisualChildren; |
|
|
|
|
|
|
|
// ReSharper disable once ForCanBeConvertedToForeach
|
|
|
|
for (int i = 0; i < children.Count; ++i) |
|
|
|
{ |
|
|
|
child.UpdateIsEffectivelyEnabled(this); |
|
|
|
var child = children[i] as InputElement; |
|
|
|
|
|
|
|
child?.UpdateIsEffectivelyEnabled(this); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|