Skip to content

Commit 250ff6b

Browse files
authored
Use explicit empty spans rather than null or empty arrays (#604)
1 parent 1d6027b commit 250ff6b

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

csharp.test/TestColumnWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static void TestWriteBatchWithNullOptionalField()
2121
var defLevels = new short[] { 1, 0, 1 };
2222
var values = new[] { 1, 2 };
2323

24-
colWriter.WriteBatch(defLevels.Length, defLevels, null, values);
24+
colWriter.WriteBatch(defLevels.Length, defLevels, ReadOnlySpan<short>.Empty, values);
2525

2626
writer.Close();
2727
}

csharp/ColumnReader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public override TReturn Apply<TReturn>(IColumnReaderVisitor<TReturn> visitor)
222222

223223
public long ReadBatch(long batchSize, Span<TValue> values, out long valuesRead)
224224
{
225-
return ReadBatch(batchSize, null, null, values, out valuesRead);
225+
return ReadBatch(batchSize, Span<short>.Empty, Span<short>.Empty, values, out valuesRead);
226226
}
227227

228228
public unsafe long ReadBatch(long batchSize, Span<short> defLevels, Span<short> repLevels, Span<TValue> values, out long valuesRead)

csharp/ColumnWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public override TReturn Apply<TReturn>(IColumnWriterVisitor<TReturn> visitor)
271271
/// <param name="values">The values to write.</param>
272272
public void WriteBatch(ReadOnlySpan<TValue> values)
273273
{
274-
WriteBatch(values.Length, null, null, values);
274+
WriteBatch(values.Length, ReadOnlySpan<short>.Empty, ReadOnlySpan<short>.Empty, values);
275275
}
276276

277277
/// <summary>

csharp/LogicalBatchWriter/ArrayWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void WriteBatch(ReadOnlySpan<TItem[]> values)
4949
{
5050
// Write zero length array
5151
_physicalWriter.WriteBatch(
52-
1, arrayDefinitionLevel, arrayRepetitionLevel, Array.Empty<TPhysical>());
52+
1, arrayDefinitionLevel, arrayRepetitionLevel, ReadOnlySpan<TPhysical>.Empty);
5353
}
5454
}
5555
else if (!_optionalArrays)
@@ -60,7 +60,7 @@ public void WriteBatch(ReadOnlySpan<TItem[]> values)
6060
{
6161
// Write a null array entry
6262
_physicalWriter.WriteBatch(
63-
1, nullDefinitionLevel, arrayRepetitionLevel, Array.Empty<TPhysical>());
63+
1, nullDefinitionLevel, arrayRepetitionLevel, ReadOnlySpan<TPhysical>.Empty);
6464
}
6565

6666
if (i == 0)

csharp/LogicalBatchWriter/OptionalNestedWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ public void WriteBatch(ReadOnlySpan<Nested<TItem>?> values)
9898
_physicalWriter.WriteBatch(
9999
nullSpanSize,
100100
_buffers.DefLevels.AsSpan(0, nullSpanSize),
101-
_buffers.RepLevels == null ? null : _buffers.RepLevels.AsSpan(0, nullSpanSize),
102-
Array.Empty<TPhysical>());
101+
_buffers.RepLevels == null ? ReadOnlySpan<short>.Empty : _buffers.RepLevels.AsSpan(0, nullSpanSize),
102+
ReadOnlySpan<TPhysical>.Empty);
103103
offset += nullSpanSize;
104104
}
105105

0 commit comments

Comments
 (0)