提交 df89375a 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #15054 from CyrusNajmabadi/funcAllocation

Cache delegates to prevent allocations.
Fixes #15052
......@@ -109,9 +109,17 @@ public static Task<SyntaxTreeIdentifierInfo> GetIdentifierInfoAsync(Document doc
return GetInfoAsync(document, s_identifierSnapshotCache, SyntaxTreeIdentifierInfo.LoadAsync, tuple => tuple.Item1, cancellationToken);
}
public static Task<SyntaxTreeDeclarationInfo> GetDeclarationInfoAsync(Document document, CancellationToken cancellationToken)
private static Func<Document, CancellationToken, Task<SyntaxTreeDeclarationInfo>> s_loadAsync
= SyntaxTreeDeclarationInfo.LoadAsync;
private static Func<ValueTuple<SyntaxTreeIdentifierInfo, SyntaxTreeContextInfo, SyntaxTreeDeclarationInfo>, SyntaxTreeDeclarationInfo> s_getThirdItem
= tuple => tuple.Item3;
public static Task<SyntaxTreeDeclarationInfo> GetDeclarationInfoAsync(
Document document, CancellationToken cancellationToken)
{
return GetInfoAsync(document, s_declaredSymbolsSnapshotCache, SyntaxTreeDeclarationInfo.LoadAsync, tuple => tuple.Item3, cancellationToken);
return GetInfoAsync(
document, s_declaredSymbolsSnapshotCache, s_loadAsync,
s_getThirdItem, cancellationToken);
}
// The probability of getting a false positive when calling ContainsIdentifier.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册