Skip to content

Commit 3e85c6a

Browse files
authored
Reduce allocations in GlyphExtensions.GetFirstGlyph (#76659)
This accounted for a small amount (0.2%) of allocations during the typing scenario of the csharpediting speedometer test.
1 parent ef02c07 commit 3e85c6a

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Features/Core/Portable/Common/GlyphExtensions.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,14 @@ public static ImmutableArray<Glyph> GetGlyphs(this ImmutableArray<string> tags)
2929

3030
public static Glyph GetFirstGlyph(this ImmutableArray<string> tags)
3131
{
32-
var glyphs = GetGlyphs(tags);
32+
foreach (var tag in tags)
33+
{
34+
var glyph = GetGlyph(tag, tags);
35+
if (glyph != Glyph.None)
36+
return glyph;
37+
}
3338

34-
return !glyphs.IsEmpty
35-
? glyphs[0]
36-
: Glyph.None;
39+
return Glyph.None;
3740
}
3841

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

0 commit comments

Comments
 (0)