Browse Source

Store property instead of id in Entry.

pull/8571/head
Steven Kirk 4 years ago
parent
commit
7f5171e04a
  1. 20
      src/Avalonia.Base/Utilities/AvaloniaPropertyValueStore.cs

20
src/Avalonia.Base/Utilities/AvaloniaPropertyValueStore.cs

@ -45,7 +45,7 @@ namespace Avalonia.Utilities
while (iHi - iLo > 3) while (iHi - iLo > 3)
{ {
int iPv = (iHi + iLo) / 2; int iPv = (iHi + iLo) / 2;
checkIndex = _entries![iPv].PropertyId; checkIndex = _entries![iPv].Property.Id;
if (propertyId == checkIndex) if (propertyId == checkIndex)
{ {
@ -66,7 +66,7 @@ namespace Avalonia.Utilities
// Now we only have three values to search; switch to a linear search // Now we only have three values to search; switch to a linear search
do do
{ {
checkIndex = _entries![iLo].PropertyId; checkIndex = _entries![iLo].Property.Id;
if (checkIndex == propertyId) if (checkIndex == propertyId)
{ {
@ -146,16 +146,14 @@ namespace Avalonia.Utilities
public void AddValue(AvaloniaProperty property, TValue value) public void AddValue(AvaloniaProperty property, TValue value)
{ {
var propertyId = property.Id; TryGetEntry(property.Id, out var index);
TryGetEntry(propertyId, out var index); InsertEntry(new Entry(property, value), index);
InsertEntry(new Entry(propertyId, value), index);
} }
public void SetValue(AvaloniaProperty property, TValue value) public void SetValue(AvaloniaProperty property, TValue value)
{ {
var propertyId = property.Id; TryGetEntry(property.Id, out var index);
TryGetEntry(propertyId, out var index); _entries![index] = new Entry(property, value);
_entries![index] = new Entry(propertyId, value);
} }
public bool Remove(AvaloniaProperty property) public bool Remove(AvaloniaProperty property)
@ -173,12 +171,12 @@ namespace Avalonia.Utilities
private readonly struct Entry private readonly struct Entry
{ {
public readonly int PropertyId; public readonly AvaloniaProperty Property;
public readonly TValue Value; public readonly TValue Value;
public Entry(int propertyId, TValue value) public Entry(AvaloniaProperty property, TValue value)
{ {
PropertyId = propertyId; Property = property;
Value = value; Value = value;
} }
} }

Loading…
Cancel
Save