Skip to content

Commit

Permalink
Read Type.GetGenericTypeDefinition just once in _isDeltaOfT (#1189)
Browse files Browse the repository at this point in the history
  • Loading branch information
senioroman4uk committed Mar 7, 2024
1 parent b19efd3 commit 12d6080
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,21 @@ internal bool IsDeltaOfT
{
get
{
if (_isDeltaOfT == null)
if (_isDeltaOfT.HasValue)
{
_isDeltaOfT = Type != null && Type.IsGenericType && (Type.GetGenericTypeDefinition() == typeof(Delta<>) ||
Type.GetGenericTypeDefinition() == typeof(DeltaSet<>) || Type.GetGenericTypeDefinition() == typeof(DeltaDeletedResource<>));
return _isDeltaOfT.Value;
}

if (!(Type is { IsGenericType: true }))
{
_isDeltaOfT = false;
return _isDeltaOfT.Value;
}

var genericTypeDefinition = Type.GetGenericTypeDefinition();
_isDeltaOfT = genericTypeDefinition == typeof(Delta<>) ||
genericTypeDefinition == typeof(DeltaSet<>) ||
genericTypeDefinition == typeof(DeltaDeletedResource<>);

return _isDeltaOfT.Value;
}
Expand Down

0 comments on commit 12d6080

Please sign in to comment.