Some code cleanup

- Simplify MaskFilter slightly
- Improve thread safety of LocalBlockVectorSet
- Simplify if statement in SingleThreadQueueExtent
- Better error in MathMan#tripleSearchCoords for handling of the error in some cases
This commit is contained in:
dordsor21
2021-09-11 16:38:01 +01:00
parent e85586db80
commit 6e586da83e
4 changed files with 9 additions and 22 deletions

View File

@ -7,7 +7,6 @@ import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
/**
* Filter with an attached Mask used for deciding whether a block is eligible for being applied to.
@ -16,25 +15,15 @@ import java.util.function.Supplier;
*/
public class MaskFilter<T extends Filter> extends DelegateFilter<T> {
private final Supplier<Mask> supplier;
private final Mask mask;
private final AtomicInteger changes;
public MaskFilter(T other, Mask mask) {
this(other, () -> mask);
public MaskFilter(T other, Mask root) {
this(other, root, new AtomicInteger());
}
public MaskFilter(T other, Supplier<Mask> supplier) {
this(other, supplier, supplier.get());
}
public MaskFilter(T other, Supplier<Mask> supplier, Mask root) {
this(other, supplier, root, new AtomicInteger());
}
public MaskFilter(T other, Supplier<Mask> supplier, Mask root, AtomicInteger changes) {
public MaskFilter(T other, Mask root, AtomicInteger changes) {
super(other);
this.supplier = supplier;
this.mask = root;
this.changes = changes;
}
@ -63,12 +52,12 @@ public class MaskFilter<T extends Filter> extends DelegateFilter<T> {
@Override
public MaskFilter<?> newInstance(Filter other) {
return new MaskFilter<>(other, supplier);
return new MaskFilter<>(other, mask);
}
@Override
public Filter fork() {
return new MaskFilter<>(getParent().fork(), mask::copy, mask.copy(), changes);
return new MaskFilter<>(getParent().fork(), mask.copy(), changes);
}
}