Skip to content

Commit a085a03

Browse files
authored
Avoid copying already copied arrays in history (#3260)
Avoid copying arrays
1 parent 5258915 commit a085a03

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

worldedit-core/src/main/java/com/fastasyncworldedit/core/history/changeset/AbstractChangeSet.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,14 @@ public final synchronized IChunkSet processSet(IChunk chunk, IChunkGet get, IChu
167167
continue;
168168
}
169169
// add each block and tile
170-
char[] blocksGet;
171-
char[] tmp = get.load(layer);
172-
if (tmp == null) {
170+
// assume "get" is a copy and doesn't get modified further
171+
char[] blocksGet = get.load(layer);
172+
if (blocksGet == null) {
173173
blocksGet = FaweCache.INSTANCE.EMPTY_CHAR_4096;
174-
} else {
175-
System.arraycopy(tmp, 0, (blocksGet = new char[4096]), 0, 4096);
176174
}
177-
char[] blocksSet;
175+
// assume "set" is a copy and doesn't get modified further
178176
// loadIfPresent shouldn't be null if set.hasSection(layer) is true
179-
System.arraycopy(Objects.requireNonNull(set.loadIfPresent(layer)), 0, (blocksSet = new char[4096]), 0, 4096);
177+
char[] blocksSet = Objects.requireNonNull(set.loadIfPresent(layer));
180178

181179
// Account for negative layers
182180
int by = layer << 4;

0 commit comments

Comments
 (0)