mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-02-26 07:23:53 +01:00
Use direct byte buffers instead of normal ones in niowrapper
This commit is contained in:
parent
e6965d0217
commit
2061d28e52
2 changed files with 2 additions and 2 deletions
|
@ -53,7 +53,7 @@ public class ProtobufClient extends MessageWriteTarget {
|
||||||
final int connectTimeoutMillis) throws IOException {
|
final int connectTimeoutMillis) throws IOException {
|
||||||
// Try to fit at least one message in the network buffer, but place an upper and lower limit on its size to make
|
// Try to fit at least one message in the network buffer, but place an upper and lower limit on its size to make
|
||||||
// sure it doesnt get too large or have to call read too often.
|
// sure it doesnt get too large or have to call read too often.
|
||||||
dbuf = ByteBuffer.allocate(Math.min(Math.max(parser.maxMessageSize, BUFFER_SIZE_LOWER_BOUND), BUFFER_SIZE_UPPER_BOUND));
|
dbuf = ByteBuffer.allocateDirect(Math.min(Math.max(parser.maxMessageSize, BUFFER_SIZE_LOWER_BOUND), BUFFER_SIZE_UPPER_BOUND));
|
||||||
parser.setWriteTarget(this);
|
parser.setWriteTarget(this);
|
||||||
sc = SocketChannel.open();
|
sc = SocketChannel.open();
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class ProtobufServer {
|
||||||
throw new IOException("Parser factory.getNewParser returned null");
|
throw new IOException("Parser factory.getNewParser returned null");
|
||||||
}
|
}
|
||||||
this.parser = newParser;
|
this.parser = newParser;
|
||||||
dbuf = ByteBuffer.allocate(Math.min(Math.max(newParser.maxMessageSize, BUFFER_SIZE_LOWER_BOUND), BUFFER_SIZE_UPPER_BOUND));
|
dbuf = ByteBuffer.allocateDirect(Math.min(Math.max(newParser.maxMessageSize, BUFFER_SIZE_LOWER_BOUND), BUFFER_SIZE_UPPER_BOUND));
|
||||||
newParser.setWriteTarget(this);
|
newParser.setWriteTarget(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue