File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
MLAPI/NetworkingManagerComponents/Binary Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 3
3
using System . Collections . Generic ;
4
4
using System . Runtime . InteropServices ;
5
5
using System . Text ;
6
+ using UnityEngine ;
6
7
7
8
namespace MLAPI . NetworkingManagerComponents . Binary
8
9
{
@@ -17,6 +18,7 @@ public class BitReader : IDisposable
17
18
private byte [ ] readFrom ;
18
19
private long bitCount = 0 ;
19
20
21
+ private static int pools = 0 ;
20
22
private static readonly Queue < BitReader > readerPool = new Queue < BitReader > ( ) ;
21
23
22
24
private BitReader ( byte [ ] readFrom )
@@ -28,7 +30,10 @@ public static BitReader Get(byte[] readFrom)
28
30
{
29
31
if ( readerPool . Count == 0 )
30
32
{
33
+ if ( pools > 10 )
34
+ Debug . LogWarning ( "MLAPI: There are more than 10 BitReaders. Have you forgotten do dispose? (More readers hurt performance)" ) ;
31
35
BitReader reader = new BitReader ( readFrom ) ;
36
+ pools ++ ;
32
37
return reader ;
33
38
}
34
39
else
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ public static BitWriter Get()
86
86
{
87
87
if ( writerPool . Count == 0 )
88
88
{
89
- Debug . LogWarning ( "MLAPI: There can be no more than 10 BitWriters. Have you forgotten do dispose? (It will still work with worse performance)" ) ;
89
+ Debug . LogWarning ( "MLAPI: There are more than 10 BitWriters. Have you forgotten do dispose? (It will still work with worse performance)" ) ;
90
90
return new BitWriter ( ) { outsidePool = true } ;
91
91
}
92
92
else
You can’t perform that action at this time.
0 commit comments