-
Bug
-
Resolution: Unresolved
-
None
-
1.16.1, 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Release Candidate 1, 1.16.2 Release Candidate 2, 1.16.2, 1.16.3, 1.16.4 Pre-release 1, 1.16.4, 20w45a, 20w46a, 20w48a, 20w49a, 20w51a, 21w03a, 1.16.5, 21w05b, 21w08b, 21w10a, 21w11a, 21w13a, 21w15a, 21w16a, 21w19a, 1.17 Pre-release 1, 1.17, 1.17.1, 21w37a, 1.18.1, 22w03a, 22w05a, 1.18.2 Pre-release 1, 1.18.2, 22w11a, 22w12a, 1.19 Release Candidate 2, 1.19, 1.19.1, 1.19.2, 1.19.3 Release Candidate 1, 1.19.3 Release Candidate 2, 1.19.3, 23w03a, 23w05a, 1.19.4 Pre-release 3, 1.19.4, 23w12a, 23w18a, 1.20.1, 23w31a, 1.20.2, 23w42a
-
Plausible
-
Commands, Performance
-
Low
-
Platform
The bug
/data merge ... and /data modify ... merge ... deep-copy the target compound tag only to check the failure of merging. This causes a significant performance penalty compared to other NBT-modifying commands that count successes incrementally.
Code analysis
net.minecraft.server.commands.data.DataCommands.java
private static int mergeData(CommandSourceStack stack, DataAccessor accessor, CompoundTag source) throws CommandSyntaxException { CompoundTag data = accessor.getData(); if (NbtPathArgument.NbtPath.isTooDeep(source, 0)) { throw NbtPathArgument.ERROR_DATA_TOO_DEEP.create(); } else { CompoundTag merged = data.copy().merge(source); // The entire data is deep-copied here. if (data.equals(merged)) { throw ERROR_MERGE_UNCHANGED.create(); } else { accessor.setData(merged); stack.sendSuccess(accessor.getModifiedSuccess(), true); return 1; } } }