Use collection expressions for empty arrays and spans

このコミットが含まれているのは:
Sergio Pedri committed 2023-11-20 23:06:22 +01:00
1 親 6d560f08e2
コミット c9a5882f43
11ファイル変更
+18 -21

検索条件に一致するファイルはありません

+1 -1
ファイルの表示
@@ -46,7 +46,7 @@
This is used eg. to replace Unsafe.SizeOf<T>() calls with just sizeof(T). The warning is not necessary
since in order to use these APIs the caller already has to be in an unsafe context.
-->
<NoWarn>$(NoWarn);CS8500;IDE0301;IDE0302</NoWarn>
<NoWarn>$(NoWarn);CS8500;IDE0302</NoWarn>
</PropertyGroup>
<!-- Centralized location for all generated artifacts -->
+1 -2
ファイルの表示
@@ -1,4 +1,3 @@
using System;
using System.Collections.Immutable;
using System.Linq;
using ComputeSharp.D2D1.SourceGenerators.Models;
@@ -94,7 +93,7 @@ public sealed partial class D2DPixelShaderSourceGenerator : IIncrementalGenerato
item.Hierarchy.WriteSyntax(
state: item,
writer: writer,
baseTypes: ReadOnlySpan<string>.Empty,
baseTypes: [],
memberCallbacks: new IndentedTextWriter.Callback<D2D1PixelShaderSourceInfo>[] { Execute.WriteSyntax });
context.AddSource($"{item.Hierarchy.FullyQualifiedMetadataName}.{item.MethodName}.g.cs", writer.ToString());
@@ -244,7 +244,7 @@ partial class PixelShaderEffect<T>
// Skip the array allocation if there are no resource texture descriptions
if (descriptions.IsEmpty)
{
return ImmutableArray<int>.Empty;
return [];
}
int[] indices = new int[descriptions.Length];
+1 -1
ファイルの表示
@@ -213,7 +213,7 @@ partial class PixelShaderEffect<T>
if (inputCount == 0)
{
return ImmutableArray<int>.Empty;
return [];
}
int[] indices = new int[inputCount];
+4 -4
ファイルの表示
@@ -140,8 +140,8 @@ public sealed unsafe class D2D1ResourceTextureManager : ICustomQueryInterface
channelDepth,
filter,
extendModes,
ReadOnlySpan<byte>.Empty,
ReadOnlySpan<uint>.Empty)
[],
[])
{
}
@@ -180,8 +180,8 @@ public sealed unsafe class D2D1ResourceTextureManager : ICustomQueryInterface
channelDepth,
filter,
extendModes,
ReadOnlySpan<byte>.Empty,
ReadOnlySpan<uint>.Empty)
[],
[])
{
}
+1 -1
ファイルの表示
@@ -143,7 +143,7 @@ internal sealed partial record HierarchyInfo(string FullyQualifiedMetadataName,
/// <returns>A <see cref="CompilationUnitSyntax"/> instance for the current hierarchy.</returns>
public CompilationUnitSyntax GetSyntax(params MemberDeclarationSyntax[] memberDeclarations)
{
return GetSyntax(memberDeclarations, Array.Empty<MemberDeclarationSyntax>());
return GetSyntax(memberDeclarations, []);
}
/// <summary>
+1 -1
ファイルの表示
@@ -121,7 +121,7 @@ internal sealed unsafe class DxcShaderCompiler
pEntryPoint: "Execute",
pTargetProfile: "cs_6_0",
pArguments: arguments.AsSpan(0, 3),
pDefines: ReadOnlySpan<DxcDefine>.Empty,
pDefines: [],
pIncludeHandler: this.dxcIncludeHandler.Get(),
ppResult: dxcOperationResult.GetAddressOf());
+1 -3
ファイルの表示
@@ -629,9 +629,7 @@ namespace ComputeSharp.D2D1.Tests
{
ShaderWithNoCapturedValues shader = default;
byte[] buffer = Array.Empty<byte>();
int bytesWritten = D2D1PixelShader.GetConstantBuffer(in shader, buffer);
int bytesWritten = D2D1PixelShader.GetConstantBuffer(in shader, []);
Assert.AreEqual(bytesWritten, 0);
}
+3 -3
ファイルの表示
@@ -158,8 +158,8 @@ public partial class D2D1ResourceTextureManagerTests
channelDepth: D2D1ChannelDepth.Four,
filter: D2D1Filter.MinMagMipPoint,
extendModes: stackalloc[] { D2D1ExtendMode.Clamp, D2D1ExtendMode.Clamp },
data: ReadOnlySpan<byte>.Empty,
strides: ReadOnlySpan<uint>.Empty);
data: [],
strides: []);
using ComPtr<ID2D1Effect> d2D1Effect = default;
@@ -596,7 +596,7 @@ public partial class D2D1ResourceTextureManagerTests
resourceTextureManager.Update(
minimumExtents: stackalloc uint[] { (uint)startOffset },
maximimumExtents: stackalloc uint[] { (uint)(startOffset + updateLength) },
strides: ReadOnlySpan<uint>.Empty,
strides: [],
data: data);
data.CopyTo(texture.AsSpan(startOffset));
+2 -2
ファイルの表示
@@ -379,7 +379,7 @@ public sealed partial class BokehBlurEffect
filter: D2D1Filter.MinMagMipPoint,
extendModes: stackalloc[] { D2D1ExtendMode.Clamp },
data: MemoryMarshal.AsBytes(this.kernels[i].Real.AsSpan()),
strides: ReadOnlySpan<uint>.Empty);
strides: []);
// Also create the one for the imaginary kernel
D2D1ResourceTextureManager kernelImaginary = new(
@@ -389,7 +389,7 @@ public sealed partial class BokehBlurEffect
filter: D2D1Filter.MinMagMipPoint,
extendModes: stackalloc[] { D2D1ExtendMode.Clamp },
data: MemoryMarshal.AsBytes(this.kernels[i].Imaginary.AsSpan()),
strides: ReadOnlySpan<uint>.Empty);
strides: []);
kernels[i] = (kernelReals, kernelImaginary);
}
+2 -2
ファイルの表示
@@ -33,7 +33,7 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
}
else
{
devices = Array.Empty<Device>();
devices = [];
}
Type[] resources = methodInfo.GetCustomAttributes<ResourceAttribute>().Select(static value => value.Type).ToArray();
@@ -272,6 +272,6 @@ public sealed class CombinatorialTestMethodAttribute : TestMethodAttribute, ITes
/// <inheritdoc/>
string? ITestDataSource.GetDisplayName(MethodInfo methodInfo, object?[]? data)
{
return $"{methodInfo.Name} ({string.Join(", ", data ?? Array.Empty<object?>())})";
return $"{methodInfo.Name} ({string.Join(", ", data ?? [])})";
}
}