mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 12:06:41 +00:00
Trim performance (#451)
* Increase performance slightly when trimming. If the chunk section is all one blocks (common in plotworlds) it'll be a nice little boost. * Cache whether blocks are ticking or not. Greatly reduces the time required to create a palette * collapse 5 lines to 2. * Also apply to 14 and 15 for the numpties * Cleanup Actually ignore the exception - remove my debug print. Remove double semi-colon * Apparently 1.14/15 matter too still.
This commit is contained in:
@ -145,4 +145,9 @@ public class CombinedBlocks implements IBlocks {
|
||||
public boolean trim(boolean aggressive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(boolean aggressive, int layer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ public interface IBlocks extends Trimable {
|
||||
.map(layer -> (1 << layer)).sum();
|
||||
}
|
||||
|
||||
boolean trim(boolean aggressive, int layer);
|
||||
|
||||
IBlocks reset();
|
||||
|
||||
default byte[] toByteArray(boolean full) {
|
||||
|
@ -153,4 +153,9 @@ public class BitSetBlocks implements IChunkSet {
|
||||
public boolean trim(boolean aggressive) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(boolean aggressive, int layer) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -60,6 +60,17 @@ public abstract class CharBlocks implements IBlocks {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(boolean aggressive, int layer) {
|
||||
boolean result = true;
|
||||
if (sections[layer] == EMPTY && blocks[layer] != null) {
|
||||
blocks[layer] = null;
|
||||
} else {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet reset() {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
@ -25,6 +25,13 @@ public abstract class CharGetBlocks extends CharBlocks implements IChunkGet {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(boolean aggressive, int layer) {
|
||||
sections[layer] = EMPTY;
|
||||
blocks[layer] = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet reset() {
|
||||
super.reset();
|
||||
|
@ -85,6 +85,11 @@ public class FallbackChunkGet implements IChunkGet {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(boolean aggressive, int layer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Future<T>> T call(IChunkSet set, Runnable finalize) {
|
||||
for (int layer = 0; layer < 16; layer++) {
|
||||
|
@ -50,6 +50,10 @@ object NullChunkGet : IChunkGet {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun trim(aggressive: Boolean, layer: Int): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun <T : Future<T>> call(set: IChunkSet, finalize: Runnable): T? {
|
||||
return null
|
||||
}
|
||||
|
@ -344,6 +344,11 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(boolean aggressive, int layer) {
|
||||
return this.trim(aggressive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return chunkSet == null || chunkSet.isEmpty();
|
||||
|
@ -117,5 +117,9 @@ object NullChunk : IQueueChunk<Nothing> {
|
||||
override fun trim(aggressive: Boolean): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun trim(aggressive: Boolean, layer: Int): Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.beta.IBatchProcessor;
|
||||
import com.boydti.fawe.beta.IChunk;
|
||||
import com.boydti.fawe.beta.IChunkGet;
|
||||
import com.boydti.fawe.beta.IChunkSet;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
||||
public class BatchProcessorHolder implements IBatchProcessorHolder {
|
||||
private IBatchProcessor processor = EmptyBatchProcessor.INSTANCE;
|
||||
|
@ -549,6 +549,11 @@ public class MCAChunk implements IChunk {
|
||||
return isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trim(boolean aggressive, int layer) {
|
||||
return hasSection(layer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getEntity(UUID uuid) {
|
||||
return this.entities.get(uuid);
|
||||
|
Reference in New Issue
Block a user