The bug
As with MC-159633, an unused component is created when a command fails during function execution. Furthermore, the component is stringified to be passed to the Exception
constructor. This imposes a constant overhead for typical command failures and a linear overhead for some command failures.
Example
The following command takes a linear time for the deep size of the target NBT on failure because it creates an exception message "Expected list, got: …" where … is the stringified target NBT.
data modify storage _ _ append value 0b
Code analysis
If a command fails, a CommandSyntaxException
is eventually created in most cases.
com.mojang.brigadier.exceptions.CommandSyntaxException
public CommandSyntaxException(final CommandExceptionType type, final Message message) {
super(message.getString(), null, ENABLE_COMMAND_STACK_TRACES, ENABLE_COMMAND_STACK_TRACES);
this.type = type;
this.message = message;
this.input = null;
this.cursor = -1;
}
The created component is converted to a string in message.getString()
, but that string and the component are never used during normal function execution.
Why exactly is this invalid? This behavior results in loss of performance, and has no effect on the game beyond that.