Skip to content

Commit

Permalink
Change the DocumentationCommentId to use a PooledStringBuilder (#73737)
Browse files Browse the repository at this point in the history
This shows as about 1% of allocations in OOP in a find references profile I'm looking at.
  • Loading branch information
ToddGrun authored May 29, 2024
1 parent 9d15715 commit 66d8f55
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Compilers/Core/Portable/DocumentationCommentId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public void ClearAndFree(List<T> list)
throw new ArgumentNullException(nameof(symbol));
}

var builder = new StringBuilder();
var builder = PooledStringBuilder.GetInstance();
var generator = new PrefixAndDeclarationGenerator(builder);
generator.Visit(symbol);

return generator.Failed ? null : builder.ToString();
return generator.Failed ? null : builder.ToStringAndFree();
}

/// <summary>
Expand Down Expand Up @@ -86,10 +86,10 @@ public static string CreateReferenceId(ISymbol symbol)
return result;
}

var builder = new StringBuilder();
var builder = PooledStringBuilder.GetInstance();
var generator = new ReferenceGenerator(builder, typeParameterContext: null);
generator.Visit(symbol);
return builder.ToString();
return builder.ToStringAndFree();
}

/// <summary>
Expand Down

0 comments on commit 66d8f55

Please sign in to comment.