-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a singleton sentinel for empty type-parameters for non-generic na…
…med-types and methods. (#68131) * Use a singleton for empty type-parameters for named types * move type parameters down * Optimize methods as well * Always create indirection * Move type * Apply suggestions from code review * speeling * nrt * Inline * Simplify * Change to abstract override
- Loading branch information
1 parent
b404fbe
commit 236149d
Showing
5 changed files
with
90 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Compilers/CSharp/Portable/Symbols/Source/TypeParameterInfo.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Immutable; | ||
|
||
namespace Microsoft.CodeAnalysis.CSharp.Symbols | ||
{ | ||
/// <summary> | ||
/// Wrapper around type-parameter/constraints/constraint-kind info. We wrap this information (instead of inlining | ||
/// directly within type/method symbols) as most types/methods are not generic. As such, all those non-generic | ||
/// types can point at the singleton sentinel <see cref="Empty"/> value, and avoid two pointers of overhead. | ||
/// </summary> | ||
internal sealed class TypeParameterInfo | ||
{ | ||
public ImmutableArray<TypeParameterSymbol> LazyTypeParameters; | ||
|
||
/// <summary> | ||
/// A collection of type parameter constraint types, populated when | ||
/// constraint types for the first type parameter are requested. | ||
/// </summary> | ||
public ImmutableArray<ImmutableArray<TypeWithAnnotations>> LazyTypeParameterConstraintTypes; | ||
|
||
/// <summary> | ||
/// A collection of type parameter constraint kinds, populated when | ||
/// constraint kinds for the first type parameter are requested. | ||
/// </summary> | ||
public ImmutableArray<TypeParameterConstraintKind> LazyTypeParameterConstraintKinds; | ||
|
||
public static readonly TypeParameterInfo Empty = new TypeParameterInfo | ||
{ | ||
LazyTypeParameters = ImmutableArray<TypeParameterSymbol>.Empty, | ||
LazyTypeParameterConstraintTypes = ImmutableArray<ImmutableArray<TypeWithAnnotations>>.Empty, | ||
LazyTypeParameterConstraintKinds = ImmutableArray<TypeParameterConstraintKind>.Empty, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters