File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
src/main/java/com/fasterxml/jackson/core/util Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -57,18 +57,26 @@ public enum CharBufferType {
57
57
58
58
public BufferRecycler () { }
59
59
60
- public final byte [] allocByteBuffer (ByteBufferType type )
60
+ public final byte [] allocByteBuffer (ByteBufferType type ) {
61
+ return allocByteBuffer (type , 0 );
62
+ }
63
+
64
+ public final byte [] allocByteBuffer (ByteBufferType type , int minSize )
61
65
{
62
- int ix = type .ordinal ();
66
+ final int ix = type .ordinal ();
67
+ final int DEF_SIZE = type .size ;
68
+ if (minSize < DEF_SIZE ) {
69
+ minSize = DEF_SIZE ;
70
+ }
63
71
byte [] buffer = _byteBuffers [ix ];
64
- if (buffer == null ) {
65
- buffer = balloc (type . size );
72
+ if (buffer == null || buffer . length < minSize ) {
73
+ buffer = balloc (minSize );
66
74
} else {
67
75
_byteBuffers [ix ] = null ;
68
76
}
69
77
return buffer ;
70
78
}
71
-
79
+
72
80
public final void releaseByteBuffer (ByteBufferType type , byte [] buffer )
73
81
{
74
82
_byteBuffers [type .ordinal ()] = buffer ;
You can’t perform that action at this time.
0 commit comments