Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2025-01-12 10:21:06 +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:
Ursprung
b54821907d
Commit
afec252dca
@ -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()) {
|
if (tx >= min.x() && bx <= max.x() && tz >= min.z() && bz <= max.z()) {
|
||||||
// contains some
|
// contains some
|
||||||
boolean processExtra = false;
|
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)) {
|
if (!set.hasSection(layer)) {
|
||||||
continue;
|
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()) {
|
if (tx >= min.x() && bx <= max.x() && tz >= min.z() && bz <= max.z()) {
|
||||||
// contains some
|
// contains some
|
||||||
boolean processExtra = false;
|
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 by = layer << 4;
|
||||||
int ty = by + 15;
|
int ty = by + 15;
|
||||||
if (containsEntireCuboid(bx, tx, by, ty, bz, tz)) {
|
if (containsEntireCuboid(bx, tx, by, ty, bz, tz)) {
|
||||||
|
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren