3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2025-01-11 18:10:52 +01:00

Optimize layer iteration to prevent performance overhead. (#3022)

* Optimize layer iteration to prevent performance overhead.

Adjusted the layer iteration logic in the Region class to use the minimum and maximum Y-values from the chunk. This prevents unnecessary iterations when getMinimumY or getMaximumY returns extreme values, improving performance efficiency.

* Optimize layer iteration logic in Region class.

Refactored the loop to reduce repeated evaluations by storing pre-calculated min and max values for Y coordinates. This change enhances readability and may improve performance by minimizing unnecessary calculations during the iteration process.

* Update variable naming

* Shift bitwise operations to variable initialization
Dieser Commit ist enthalten in:
David 2024-12-15 01:56:07 +01:00 committet von GitHub
Ursprung b54821907d
Commit afec252dca
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194

Datei anzeigen

@ -403,7 +403,9 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
if (tx >= min.x() && bx <= max.x() && tz >= min.z() && bz <= max.z()) {
// contains some
boolean processExtra = false;
for (int layer = getMinimumY() >> 4; layer <= getMaximumY() >> 4; layer++) {
final int minLayer = Math.max(getMinimumY(), chunk.getMinY()) >> 4;
final int maxLayer = Math.min(getMaximumY(), chunk.getMaxY()) >> 4;
for (int layer = minLayer; layer <= maxLayer; layer++) {
if (!set.hasSection(layer)) {
continue;
}
@ -457,7 +459,9 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
if (tx >= min.x() && bx <= max.x() && tz >= min.z() && bz <= max.z()) {
// contains some
boolean processExtra = false;
for (int layer = getMinimumY() >> 4; layer <= getMaximumY() >> 4; layer++) {
final int minLayer = Math.max(getMinimumY(), chunk.getMinY()) >> 4;
final int maxLayer = Math.min(getMaximumY(), chunk.getMaxY()) >> 4;
for (int layer = minLayer; layer <= maxLayer; layer++) {
int by = layer << 4;
int ty = by + 15;
if (containsEntireCuboid(bx, tx, by, ty, bz, tz)) {