Browse Source

Go direct to ValueStore for untyped GetValue.

Avoids a virtual call in the case of styled properties.
pull/8600/head
Steven Kirk 4 years ago
parent
commit
ba4bfc36f8
  1. 10
      src/Avalonia.Base/AvaloniaObject.cs
  2. 2
      src/Avalonia.Base/PropertyStore/ValueStore.cs

10
src/Avalonia.Base/AvaloniaObject.cs

@ -206,7 +206,15 @@ namespace Avalonia
/// </summary>
/// <param name="property">The property.</param>
/// <returns>The value.</returns>
public object? GetValue(AvaloniaProperty property) => property.RouteGetValue(this);
public object? GetValue(AvaloniaProperty property)
{
_ = property ?? throw new ArgumentNullException(nameof(property));
if (property.IsDirect)
return property.RouteGetValue(this);
else
return _values.GetValue(property);
}
/// <summary>
/// Gets a <see cref="AvaloniaProperty"/> value.

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

@ -2,12 +2,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Avalonia.Collections.Pooled;
using Avalonia.Data;
using Avalonia.Diagnostics;
using Avalonia.Logging;
using Avalonia.Utilities;
using JetBrains.Annotations;
namespace Avalonia.PropertyStore
{

Loading…
Cancel
Save