Do not fallback to waiting list

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-04-02 23:35:11 +02:00
parent ff8dd0cdaa
commit 7a371fe616

View File

@ -415,11 +415,10 @@ public class PlayerSocketConnection extends PlayerConnection {
public void flushSync() throws IOException { public void flushSync() throws IOException {
final SocketChannel channel = this.channel; final SocketChannel channel = this.channel;
final List<BinaryBuffer> waitingBuffers = this.waitingBuffers; final List<BinaryBuffer> waitingBuffers = this.waitingBuffers;
if (!channel.isConnected()) throw new ClosedChannelException(); if (!channel.isConnected()) throw new ClosedChannelException();
// Fast exit if the tick buffer can be reused if (waitingBuffers.isEmpty()) {
if (waitingBuffers.isEmpty() && tickBuffer.getPlain().writeChannel(channel)) tickBuffer.getPlain().writeChannel(channel);
return; } else {
// Write as much as possible from the waiting list // Write as much as possible from the waiting list
Iterator<BinaryBuffer> iterator = waitingBuffers.iterator(); Iterator<BinaryBuffer> iterator = waitingBuffers.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -429,6 +428,7 @@ public class PlayerSocketConnection extends PlayerConnection {
PooledBuffers.add(waitingBuffer); PooledBuffers.add(waitingBuffer);
} }
} }
}
private BinaryBuffer updateLocalBuffer() { private BinaryBuffer updateLocalBuffer() {
BinaryBuffer newBuffer = PooledBuffers.get(); BinaryBuffer newBuffer = PooledBuffers.get();