Do not create unneccessary callback in ChunkTaskScheduler#scheduleChunkLoad
If the parameter has addTicket = false and onComplete = null, then the loadCallback would do no work and as a result does not need to be created.
This commit is contained in:
@@ -579,7 +579,7 @@ public final class ChunkTaskScheduler {
|
|||||||
this.chunkHolderManager.processTicketUpdates();
|
this.chunkHolderManager.processTicketUpdates();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Consumer<ChunkAccess> loadCallback = (final ChunkAccess chunk) -> {
|
final Consumer<ChunkAccess> loadCallback = onComplete == null && !addTicket ? null : (final ChunkAccess chunk) -> {
|
||||||
try {
|
try {
|
||||||
if (onComplete != null) {
|
if (onComplete != null) {
|
||||||
onComplete.accept(chunk);
|
onComplete.accept(chunk);
|
||||||
@@ -616,7 +616,9 @@ public final class ChunkTaskScheduler {
|
|||||||
if (!chunkHolder.upgradeGenTarget(toStatus)) {
|
if (!chunkHolder.upgradeGenTarget(toStatus)) {
|
||||||
this.schedule(chunkX, chunkZ, toStatus, chunkHolder, tasks);
|
this.schedule(chunkX, chunkZ, toStatus, chunkHolder, tasks);
|
||||||
}
|
}
|
||||||
chunkHolder.addStatusConsumer(toStatus, loadCallback);
|
if (loadCallback != null) {
|
||||||
|
chunkHolder.addStatusConsumer(toStatus, loadCallback);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -630,7 +632,7 @@ public final class ChunkTaskScheduler {
|
|||||||
tasks.get(i).schedule();
|
tasks.get(i).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scheduled) {
|
if (loadCallback != null && !scheduled) {
|
||||||
// couldn't schedule
|
// couldn't schedule
|
||||||
try {
|
try {
|
||||||
loadCallback.accept(chunk);
|
loadCallback.accept(chunk);
|
||||||
|
|||||||
Reference in New Issue
Block a user