From 0c4aae061b997c1de215432023f652d5ebeda8d5 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Mon, 25 Jul 2022 23:12:53 +0200 Subject: [PATCH] Special-case frames with one entry. Seems it's slightly faster to re-evaluate the single value in this case. --- src/Avalonia.Base/PropertyStore/ValueStore.cs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Avalonia.Base/PropertyStore/ValueStore.cs b/src/Avalonia.Base/PropertyStore/ValueStore.cs index 8d6a1ae6c9..e6126f7973 100644 --- a/src/Avalonia.Base/PropertyStore/ValueStore.cs +++ b/src/Avalonia.Base/PropertyStore/ValueStore.cs @@ -419,7 +419,16 @@ namespace Avalonia.PropertyStore /// The frame which produced the change. public void OnFrameActivationChanged(ValueFrame frame) { - ReevaluateEffectiveValues(); + if (frame.EntryCount == 0) + return; + else if (frame.EntryCount == 1) + { + var property = frame.GetEntry(0).Property; + _effectiveValues.TryGetValue(property, out var current); + ReevaluateEffectiveValue(property, current); + } + else + ReevaluateEffectiveValues(); } /// @@ -637,7 +646,7 @@ namespace Avalonia.PropertyStore private void ReevaluateEffectiveValue( AvaloniaProperty property, - EffectiveValue current, + EffectiveValue? current, bool ignoreLocalValue = false) { if (EvaluateEffectiveValue( @@ -648,12 +657,18 @@ namespace Avalonia.PropertyStore out var baseValue, out var basePriority)) { + if (current is null) + { + current = property.CreateEffectiveValue(Owner); + AddEffectiveValue(property, current); + } + if (basePriority != BindingPriority.Unset) current.SetAndRaise(this, property, value, priority, baseValue, basePriority); else current.SetAndRaise(this, property, value, priority); } - else + else if (current is not null) { RemoveEffectiveValue(property); current.DisposeAndRaiseUnset(this, property);