Skip to content

Commit abe16a1

Browse files
committed
chore: refactor block vector handling in loops
1 parent 5c78836 commit abe16a1

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.fastasyncworldedit.core.configuration.Caption;
2323
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
2424
import com.fastasyncworldedit.core.function.mask.IdMask;
25+
import com.fastasyncworldedit.core.math.MutableBlockVector3;
2526
import com.fastasyncworldedit.core.regions.selector.FuzzyRegionSelector;
2627
import com.fastasyncworldedit.core.regions.selector.PolyhedralRegionSelector;
2728
import com.fastasyncworldedit.core.util.MaskTraverser;
@@ -536,12 +537,13 @@ public void trim(Actor actor, World world, LocalSession session,
536537
int minY = 0;
537538
boolean found = false;
538539

540+
MutableBlockVector3 mutable = new MutableBlockVector3();
539541
outer: for (int y = min.y(); y <= max.y(); y++) {
540542
for (int x = min.x(); x <= max.x(); x++) {
541543
for (int z = min.z(); z <= max.z(); z++) {
542-
BlockVector3 vec = BlockVector3.at(x, y, z);
544+
mutable.setComponents(x, y, z);
543545

544-
if (mask.test(vec)) {
546+
if (mask.test(mutable)) {
545547
found = true;
546548
minY = y;
547549

@@ -561,9 +563,9 @@ public void trim(Actor actor, World world, LocalSession session,
561563
outer: for (int y = max.y(); y > minY; y--) {
562564
for (int x = min.x(); x <= max.x(); x++) {
563565
for (int z = min.z(); z <= max.z(); z++) {
564-
BlockVector3 vec = BlockVector3.at(x, y, z);
566+
mutable.setComponents(x, y, z);
565567

566-
if (mask.test(vec)) {
568+
if (mask.test(mutable)) {
567569
maxY = y;
568570
break outer;
569571
}
@@ -576,9 +578,9 @@ public void trim(Actor actor, World world, LocalSession session,
576578
outer: for (int x = min.x(); x <= max.x(); x++) {
577579
for (int z = min.z(); z <= max.z(); z++) {
578580
for (int y = minY; y <= maxY; y++) {
579-
BlockVector3 vec = BlockVector3.at(x, y, z);
581+
mutable.setComponents(x, y, z);
580582

581-
if (mask.test(vec)) {
583+
if (mask.test(mutable)) {
582584
minX = x;
583585
break outer;
584586
}
@@ -591,9 +593,9 @@ public void trim(Actor actor, World world, LocalSession session,
591593
outer: for (int x = max.x(); x > minX; x--) {
592594
for (int z = min.z(); z <= max.z(); z++) {
593595
for (int y = minY; y <= maxY; y++) {
594-
BlockVector3 vec = BlockVector3.at(x, y, z);
596+
mutable.setComponents(x, y, z);
595597

596-
if (mask.test(vec)) {
598+
if (mask.test(mutable)) {
597599
maxX = x;
598600
break outer;
599601
}
@@ -606,9 +608,9 @@ public void trim(Actor actor, World world, LocalSession session,
606608
outer: for (int z = min.z(); z <= max.z(); z++) {
607609
for (int x = minX; x <= maxX; x++) {
608610
for (int y = minY; y <= maxY; y++) {
609-
BlockVector3 vec = BlockVector3.at(x, y, z);
611+
mutable.setComponents(x, y, z);
610612

611-
if (mask.test(vec)) {
613+
if (mask.test(mutable)) {
612614
minZ = z;
613615
break outer;
614616
}
@@ -621,9 +623,9 @@ public void trim(Actor actor, World world, LocalSession session,
621623
outer: for (int z = max.z(); z > minZ; z--) {
622624
for (int x = minX; x <= maxX; x++) {
623625
for (int y = minY; y <= maxY; y++) {
624-
BlockVector3 vec = BlockVector3.at(x, y, z);
626+
mutable.setComponents(x, y, z);
625627

626-
if (mask.test(vec)) {
628+
if (mask.test(mutable)) {
627629
maxZ = z;
628630
break outer;
629631
}

0 commit comments

Comments
 (0)