From b06d943f7c9ea64749a0b1ffd147c38ef6ad2e31 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 4 Oct 2020 18:49:45 +0100 Subject: [PATCH] There's no need to duplicate everything when copying the intersection masks, as the Set and array should be the same. (#680) * There's no need to duplicate everything when copying the intersection masks, as the Set and array should be the same. * do the same for Union mask --- .../sk89q/worldedit/function/mask/MaskIntersection.java | 9 +-------- .../com/sk89q/worldedit/function/mask/MaskUnion.java | 8 +------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java index ccad2158b..d4404176d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskIntersection.java @@ -61,12 +61,6 @@ public class MaskIntersection extends AbstractMask { formArray(); } - protected MaskIntersection(Set masks, Mask[] masksArray, boolean defaultReturn) { - this.masks = masks; - this.masksArray = masksArray; - this.defaultReturn = defaultReturn; - } - public static Mask of(Mask... masks) { Set set = new LinkedHashSet<>(); for (Mask mask : masks) { @@ -260,8 +254,7 @@ public class MaskIntersection extends AbstractMask { @Override public Mask copy(){ Set masks = this.masks.stream().map(Mask::copy).collect(Collectors.toSet()); - Mask[] maskArray = (Mask[]) Arrays.stream(this.masksArray).map(Mask::copy).toArray(); - return new MaskIntersection(masks, maskArray, this.defaultReturn); + return new MaskIntersection(masks); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java index 356d3e748..25174efd6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/MaskUnion.java @@ -22,7 +22,6 @@ package com.sk89q.worldedit.function.mask; import com.sk89q.worldedit.math.BlockVector3; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashSet; import java.util.List; @@ -57,10 +56,6 @@ public class MaskUnion extends MaskIntersection { super(mask); } - private MaskUnion(Set masks, Mask[] maskArray, boolean defaultReturn) { - super(masks, maskArray, defaultReturn); - } - public static Mask of(Mask... masks) { Set set = new LinkedHashSet<>(); for (Mask mask : masks) { @@ -121,7 +116,6 @@ public class MaskUnion extends MaskIntersection { @Override public Mask copy() { Set masksCopy = masks.stream().map(Mask::copy).collect(Collectors.toSet()); - Mask[] maskArray = (Mask[]) Arrays.stream(masksArray).map(Mask::copy).toArray(); - return new MaskUnion(masksCopy, maskArray, defaultReturn); + return new MaskUnion(masksCopy); } }