From dfae2e6510b512cf981868330dc5977d9026fdcc Mon Sep 17 00:00:00 2001 From: CyrusNajmabadi Date: Mon, 15 May 2017 17:28:39 -0700 Subject: [PATCH] Fix perf regression in gotodef. --- .../GoToDefinition/GoToDefinitionHelpers.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs index c76ae32e975..fc576377d12 100644 --- a/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs +++ b/src/EditorFeatures/Core/GoToDefinition/GoToDefinitionHelpers.cs @@ -61,8 +61,27 @@ internal static class GoToDefinitionHelpers } var definitions = ArrayBuilder.GetInstance(); - var definitionItem = symbol.ToClassifiedDefinitionItemAsync( - solution, includeHiddenLocations: true, cancellationToken: cancellationToken).WaitAndGetResult(cancellationToken); + + // Going to a symbol may end up actually showing the symbol in the Find-Usages window. + // This happens when there is more than one location for the symbol (i.e. for partial + // symbols) and we don't know the best place to take you to. + // + // The FindUsages window supports showing the classified text for an item. It does this + // in two ways. Either the item can pass along its classified text (and the window will + // defer to that), or the item will have no classified text, and the window will compute + // it in the BG. + // + // Passing along the classified information is valuable for OOP scenarios where we want + // all that expensive computation done on the OOP side and not in the VS side. + // + // However, Go To Definition is all in-process, and is also synchronous. So we do not + // want to fetch the classifications here. It slows down the command and leads to a + // measurable delay in our perf tests. + // + // So, if we only have a single location to go to, this does no unnecessary work. And, + // if we do have multiple locations to show, it will just be done in the BG, unblocking + // this command thread so it can return the user faster. + var definitionItem = symbol.ToNonClassifiedDefinitionItem(solution, includeHiddenLocations: true); if (thirdPartyNavigationAllowed) { -- GitLab