From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: virustotalop Date: Thu, 16 Apr 2020 20:51:32 -0700 Subject: [PATCH] Optimize brigadier child sorting performance diff --git a/src/main/java/com/mojang/brigadier/tree/CommandNode.java b/src/main/java/com/mojang/brigadier/tree/CommandNode.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/com/mojang/brigadier/tree/CommandNode.java +++ b/src/main/java/com/mojang/brigadier/tree/CommandNode.java @@ -0,0 +0,0 @@ import java.util.stream.Collectors; import net.minecraft.commands.CommandListenerWrapper; // CraftBukkit public abstract class CommandNode implements Comparable> { - private Map> children = Maps.newLinkedHashMap(); + private Map> children = Maps.newTreeMap(); //Paper - Switch to tree map for automatic sorting private Map> literals = Maps.newLinkedHashMap(); private Map> arguments = Maps.newLinkedHashMap(); private final Predicate requirement; @@ -0,0 +0,0 @@ public abstract class CommandNode implements Comparable> { arguments.put(node.getName(), (ArgumentCommandNode) node); } } - - children = children.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new)); + //Paper - Remove manual sorting, it is no longer needed } public void findAmbiguities(final AmbiguityConsumer consumer) {