Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce LOH allocations for SemanticToken classification in LSP #69496

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Classification;
using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
Expand Down Expand Up @@ -59,7 +59,7 @@ private static async Task<ClassifiedSpan[]> GetClassifiedSpansForDocumentAsync(
CancellationToken cancellationToken)
{
var classificationService = document.GetRequiredLanguageService<IClassificationService>();
using var _ = ArrayBuilder<ClassifiedSpan>.GetInstance(out var classifiedSpans);
using var _ = Classifier.GetPooledList(out var classifiedSpans);

// We always return both syntactic and semantic classifications. If there is a syntactic classifier running on the client
// then the semantic token classifications will override them.
Expand All @@ -82,7 +82,7 @@ private static async Task<ClassifiedSpan[]> GetClassifiedSpansForDocumentAsync(

public static ClassifiedSpan[] ConvertMultiLineToSingleLineSpans(SourceText text, ClassifiedSpan[] classifiedSpans)
{
using var _ = ArrayBuilder<ClassifiedSpan>.GetInstance(out var updatedClassifiedSpans);
using var _ = Classifier.GetPooledList(out var updatedClassifiedSpans);

for (var spanIndex = 0; spanIndex < classifiedSpans.Length; spanIndex++)
{
Expand All @@ -109,7 +109,7 @@ public static ClassifiedSpan[] ConvertMultiLineToSingleLineSpans(SourceText text
static void ConvertToSingleLineSpan(
SourceText text,
ClassifiedSpan[] originalClassifiedSpans,
ArrayBuilder<ClassifiedSpan> updatedClassifiedSpans,
SegmentedList<ClassifiedSpan> updatedClassifiedSpans,
ref int spanIndex,
string classificationType,
int startLine,
Expand Down