mirror of
https://github.com/Minestom/Minestom.git
synced 2024-06-22 20:44:54 +02:00
Fast exit if tick buffer can be reused
Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
parent
cecaab762d
commit
785bcb8b6d
|
@ -441,13 +441,17 @@ public class PlayerSocketConnection extends PlayerConnection {
|
|||
try {
|
||||
if (!channel.isConnected()) throw new ClosedChannelException();
|
||||
try {
|
||||
updateLocalBuffer();
|
||||
} catch (OutOfMemoryError e) {
|
||||
this.waitingBuffers.clear();
|
||||
System.gc(); // Explicit gc forcing buffers to be collected
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
try {
|
||||
if (waitingBuffers.isEmpty() && tickBuffer.getPlain().writeChannel(channel))
|
||||
return; // Fast exit if the tick buffer can be reused
|
||||
|
||||
try {
|
||||
updateLocalBuffer();
|
||||
} catch (OutOfMemoryError e) {
|
||||
this.waitingBuffers.clear();
|
||||
System.gc(); // Explicit gc forcing buffers to be collected
|
||||
throw new ClosedChannelException();
|
||||
}
|
||||
|
||||
// Write as much as possible from the waiting list
|
||||
Iterator<BinaryBuffer> iterator = waitingBuffers.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user