Skip to content

Commit

Permalink
avoid delegate creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Dec 29, 2023
1 parent c9a64a8 commit 761176e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Maui.DataGrid/Extensions/ReflectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ internal static class ReflectionExtensions

private static object? GetPropertyValue(object obj, string propertyName)
{
var properties = PropertyTypeCache.GetOrAdd(obj.GetType(), _ => TypeDescriptor.GetProperties(obj));
var type = obj.GetType();

if (!PropertyTypeCache.TryGetValue(type, out var properties))
{
properties = TypeDescriptor.GetProperties(obj);
PropertyTypeCache[type] = properties;
}

var propertyDescriptor = properties.Find(propertyName, false);

Expand Down

0 comments on commit 761176e

Please sign in to comment.