Skip to content

Commit

Permalink
perf: simplify NetworkWriter/Reader dispose (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpach committed Oct 23, 2020
1 parent ea0340e commit bf62345
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
8 changes: 1 addition & 7 deletions Assets/Mirror/Runtime/NetworkReaderPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,13 @@ namespace Mirror
/// <summary>
/// NetworkReader to be used with <see cref="NetworkReaderPool">NetworkReaderPool</see>
/// </summary>
public class PooledNetworkReader : NetworkReader, IDisposable
public sealed class PooledNetworkReader : NetworkReader, IDisposable
{
internal PooledNetworkReader(byte[] bytes) : base(bytes) { }

internal PooledNetworkReader(ArraySegment<byte> segment) : base(segment) { }

public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}

public virtual void Dispose(bool disposing)
{
NetworkReaderPool.Recycle(this);
}
Expand Down
8 changes: 1 addition & 7 deletions Assets/Mirror/Runtime/NetworkWriterPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,9 @@ namespace Mirror
/// <summary>
/// NetworkWriter to be used with <see cref="NetworkWriterPool">NetworkWriterPool</see>
/// </summary>
public class PooledNetworkWriter : NetworkWriter, IDisposable
public sealed class PooledNetworkWriter : NetworkWriter, IDisposable
{
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}

public virtual void Dispose(bool disposing)
{
NetworkWriterPool.Recycle(this);
}
}
Expand Down

0 comments on commit bf62345

Please sign in to comment.