Skip to content

Commit

Permalink
Reduce allocations in GlyphExtensions.GetFirstGlyph (#76659)
Browse files Browse the repository at this point in the history
This accounted for a small amount (0.2%) of allocations during the typing scenario of the csharpediting speedometer test.
  • Loading branch information
ToddGrun authored Jan 7, 2025
1 parent ef02c07 commit 3e85c6a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Features/Core/Portable/Common/GlyphExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ public static ImmutableArray<Glyph> GetGlyphs(this ImmutableArray<string> tags)

public static Glyph GetFirstGlyph(this ImmutableArray<string> tags)
{
var glyphs = GetGlyphs(tags);
foreach (var tag in tags)
{
var glyph = GetGlyph(tag, tags);
if (glyph != Glyph.None)
return glyph;
}

return !glyphs.IsEmpty
? glyphs[0]
: Glyph.None;
return Glyph.None;
}

private static Glyph GetGlyph(string tag, ImmutableArray<string> allTags)
Expand Down

0 comments on commit 3e85c6a

Please sign in to comment.