3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00:00

Use direct byte buffers instead of normal ones in niowrapper

This commit is contained in:
Matt Corallo 2013-07-09 16:36:15 +02:00 committed by Mike Hearn
parent e6965d0217
commit 2061d28e52
2 changed files with 2 additions and 2 deletions

View File

@ -53,7 +53,7 @@ public class ProtobufClient extends MessageWriteTarget {
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
// 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);
sc = SocketChannel.open();

View File

@ -64,7 +64,7 @@ public class ProtobufServer {
throw new IOException("Parser factory.getNewParser returned null");
}
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);
}