Use pooled array builders in all generators
このコミットが含まれているのは:
1 親
d4b1e71c39
コミット
883d99ca9f
31ファイル変更
+320
-205
検索条件に一致するファイルはありません
+11
-7
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using ComputeSharp.D2D1.SourceGenerators.Models;
|
||||
using ComputeSharp.SourceGeneration.Extensions;
|
||||
using ComputeSharp.SourceGeneration.Helpers;
|
||||
using ComputeSharp.SourceGeneration.Models;
|
||||
using Microsoft.CodeAnalysis;
|
||||
using static ComputeSharp.SourceGeneration.Diagnostics.DiagnosticDescriptors;
|
||||
@@ -24,12 +24,13 @@ partial class ID2D1ShaderGenerator
|
||||
/// <param name="structDeclarationSymbol">The input <see cref="INamedTypeSymbol"/> instance to process.</param>
|
||||
/// <param name="inputDescriptions">The produced input descriptions for the shader.</param>
|
||||
public static void GetInfo(
|
||||
ImmutableArray<DiagnosticInfo>.Builder diagnostics,
|
||||
ImmutableArrayBuilder<DiagnosticInfo> diagnostics,
|
||||
INamedTypeSymbol structDeclarationSymbol,
|
||||
out ImmutableArray<InputDescription> inputDescriptions)
|
||||
{
|
||||
int inputCount = 0;
|
||||
ImmutableArray<InputDescription>.Builder inputDescriptionsBuilder = ImmutableArray.CreateBuilder<InputDescription>();
|
||||
|
||||
using ImmutableArrayBuilder<InputDescription> inputDescriptionsBuilder = ImmutableArrayBuilder<InputDescription>.Rent();
|
||||
|
||||
foreach (AttributeData attributeData in structDeclarationSymbol.GetAttributes())
|
||||
{
|
||||
@@ -63,17 +64,20 @@ partial class ID2D1ShaderGenerator
|
||||
}
|
||||
|
||||
// All simple indices must be in range
|
||||
if (inputDescriptionsBuilder.Any(description => description.Index >= inputCount))
|
||||
foreach (InputDescription inputDescription in inputDescriptionsBuilder.WrittenSpan)
|
||||
{
|
||||
diagnostics.Add(OutOfRangeInputDescriptionIndex, structDeclarationSymbol, structDeclarationSymbol);
|
||||
if (inputDescription.Index >= inputCount)
|
||||
{
|
||||
diagnostics.Add(OutOfRangeInputDescriptionIndex, structDeclarationSymbol, structDeclarationSymbol);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Span<bool> selectedInputDescriptionIndices = stackalloc bool[8];
|
||||
|
||||
// All input description indices must be unique
|
||||
foreach (InputDescription inputDescription in inputDescriptionsBuilder)
|
||||
foreach (InputDescription inputDescription in inputDescriptionsBuilder.WrittenSpan)
|
||||
{
|
||||
ref bool isInputDescriptionIndexUsed = ref selectedInputDescriptionIndices[(int)inputDescription.Index];
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする