Skip to content

Commit

Permalink
Update Writer.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
IEvangelist authored Sep 5, 2023
1 parent c8c253a commit ffb3a99
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Orleans.Serialization/Buffers/Writer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,12 @@ internal Writer(TBufferWriter output, Span<byte> span, SerializerSession session
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose()
{
// Avoid boxing the struct, for better perf and codegen.
if (typeof(TBufferWriter).IsValueType)
{
if (Output is IDisposable disposable)
if (Output is IDisposable)
{
disposable.Dispose();
((IDisposable)Output).Dispose();
}
}
else
Expand Down Expand Up @@ -548,4 +549,4 @@ private void WriteVarUInt64Slow(ulong value)
BinaryPrimitives.WriteUInt16LittleEndian(_currentSpan.Slice(sizeof(ulong)), (ushort)upper);
}
}
}
}

0 comments on commit ffb3a99

Please sign in to comment.