Browse Source

Special-case frames with one entry.

Seems it's slightly faster to re-evaluate the single value in this case.
refactor/style-priorities
Steven Kirk 4 years ago
parent
commit
0c4aae061b
  1. 21
      src/Avalonia.Base/PropertyStore/ValueStore.cs

21
src/Avalonia.Base/PropertyStore/ValueStore.cs

@ -419,7 +419,16 @@ namespace Avalonia.PropertyStore
/// <param name="frame">The frame which produced the change.</param>
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();
}
/// <summary>
@ -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);

Loading…
Cancel
Save