3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-08 22:02:50 +02:00

Use ArrayDeque, less ram for PacketWrapper.readableObjects (#2218)

Dieser Commit ist enthalten in:
creeper123123321 2020-12-07 07:50:52 -03:00 committet von GitHub
Ursprung 137680ed9f
Commit d75420a35b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -15,8 +15,9 @@ import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.util.PipelineUtil;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Deque;
import java.util.List;
import java.util.NoSuchElementException;
@ -28,7 +29,7 @@ public class PacketWrapper {
private final UserConnection userConnection;
private boolean send = true;
private int id = -1;
private final LinkedList<Pair<Type, Object>> readableObjects = new LinkedList<>();
private final Deque<Pair<Type, Object>> readableObjects = new ArrayDeque<>();
private final List<Pair<Type, Object>> packetValues = new ArrayList<>();
public PacketWrapper(int packetID, ByteBuf inputBuffer, UserConnection userConnection) {
@ -488,7 +489,9 @@ public class PacketWrapper {
*/
public void resetReader() {
// Move all packet values to the readable for next packet.
this.readableObjects.addAll(0, packetValues);
for (int i = packetValues.size() - 1; i >= 0; i--) {
this.readableObjects.addFirst(this.packetValues.get(i));
}
this.packetValues.clear();
}