Skip to content

Commit 01de853

Browse files
authored
test: Update benchmark code to compile with C#14 (#89)
C#14 has a breaking change. It prefers to use ReadOnlySpan when doing an implicit conversion from an array. Use an explicit method as we a conversion to a normal Span.
1 parent cc5d89c commit 01de853

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

benchmark/Micro/GenericColorTransformation.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public void Init()
109109
public void TransformHP1Explicit()
110110
{
111111
var sourceTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_source);
112-
var destinationTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_destination);
112+
var destinationTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_destination.AsSpan());
113113

114114
for (int i = 0; i < PixelCount; ++i)
115115
{
@@ -122,7 +122,7 @@ public void TransformHP1Explicit()
122122
public void TransformHP1ExplicitIntParameters()
123123
{
124124
var sourceTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_source);
125-
var destinationTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_destination);
125+
var destinationTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_destination.AsSpan());
126126

127127
for (int i = 0; i < PixelCount; ++i)
128128
{
@@ -135,7 +135,7 @@ public void TransformHP1ExplicitIntParameters()
135135
public void TransformHP1ExplicitIntParametersReturnTripletByte()
136136
{
137137
var sourceTriplet = MemoryMarshal.Cast<byte, TripletByte>(_source);
138-
var destinationTriplet = MemoryMarshal.Cast<byte, TripletByte>(_destination);
138+
var destinationTriplet = MemoryMarshal.Cast<byte, TripletByte>(_destination.AsSpan());
139139

140140
for (int i = 0; i < PixelCount; ++i)
141141
{
@@ -195,7 +195,7 @@ public void TransformHP1PerByte()
195195
public void TransformHP1Generic()
196196
{
197197
var sourceTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_source);
198-
var destinationTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_destination);
198+
var destinationTriplet = MemoryMarshal.Cast<byte, Triplet<byte>>(_destination.AsSpan());
199199

200200
for (int i = 0; i < PixelCount; ++i)
201201
{

0 commit comments

Comments
 (0)