Skip to content

Commit

Permalink
chore: remove allocation from GetAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison committed Jul 11, 2023
1 parent ae1ada4 commit 8ca1d91
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Riok.Mapperly/Descriptors/SymbolAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ internal IEnumerable<AttributeData> GetAttributes<T>(ISymbol symbol)
where T : Attribute
{
var attributeSymbol = _types.Get<T>();
return GetAttributesCore(symbol)
.Where(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass?.ConstructedFrom ?? x.AttributeClass, attributeSymbol));
foreach (var attr in GetAttributesCore(symbol))
{
if (SymbolEqualityComparer.Default.Equals(attr.AttributeClass?.ConstructedFrom ?? attr.AttributeClass, attributeSymbol))
{
yield return attr;
}
}
}

internal bool HasAttribute<T>(ISymbol symbol)
Expand Down

0 comments on commit 8ca1d91

Please sign in to comment.