diff options
author | Spottedleaf <[email protected]> | 2024-11-18 22:47:09 -0800 |
---|---|---|
committer | Spottedleaf <[email protected]> | 2024-11-18 23:02:17 -0800 |
commit | 37b9630f6a891489cf27353518cc701c1acfd288 (patch) | |
tree | cb7ff860053e11241720eba0a7d6ce04aadafd96 | |
parent | 8c5b837e0530ffd7881336be1ed77a5cd2e591e1 (diff) | |
download | Paper-37b9630f6a891489cf27353518cc701c1acfd288.tar.gz Paper-37b9630f6a891489cf27353518cc701c1acfd288.zip |
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.
-rw-r--r-- | patches/server/1038-Moonrise-optimisation-patches.patch | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/patches/server/1038-Moonrise-optimisation-patches.patch b/patches/server/1038-Moonrise-optimisation-patches.patch index 28100bbfb0..639d23f48b 100644 --- a/patches/server/1038-Moonrise-optimisation-patches.patch +++ b/patches/server/1038-Moonrise-optimisation-patches.patch @@ -8246,10 +8246,10 @@ index 0000000000000000000000000000000000000000..91a6f57f35fc1553159cca138a0619e7 +} diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java new file mode 100644 -index 0000000000000000000000000000000000000000..877e48375ac987169011051108c6c5102f8c0590 +index 0000000000000000000000000000000000000000..b0bfe655922877676948d9b6ff3fa5a6ebb7a640 --- /dev/null +++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java -@@ -0,0 +1,1036 @@ +@@ -0,0 +1,1038 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.scheduling; + +import ca.spottedleaf.concurrentutil.executor.PrioritisedExecutor; @@ -8831,7 +8831,7 @@ index 0000000000000000000000000000000000000000..877e48375ac987169011051108c6c510 + this.chunkHolderManager.processTicketUpdates(); + } + -+ final Consumer<ChunkAccess> loadCallback = (final ChunkAccess chunk) -> { ++ final Consumer<ChunkAccess> loadCallback = onComplete == null && !addTicket ? null : (final ChunkAccess chunk) -> { + try { + if (onComplete != null) { + onComplete.accept(chunk); @@ -8868,7 +8868,9 @@ index 0000000000000000000000000000000000000000..877e48375ac987169011051108c6c510 + if (!chunkHolder.upgradeGenTarget(toStatus)) { + this.schedule(chunkX, chunkZ, toStatus, chunkHolder, tasks); + } -+ chunkHolder.addStatusConsumer(toStatus, loadCallback); ++ if (loadCallback != null) { ++ chunkHolder.addStatusConsumer(toStatus, loadCallback); ++ } + } + } + } finally { @@ -8882,7 +8884,7 @@ index 0000000000000000000000000000000000000000..877e48375ac987169011051108c6c510 + tasks.get(i).schedule(); + } + -+ if (!scheduled) { ++ if (loadCallback != null && !scheduled) { + // couldn't schedule + try { + loadCallback.accept(chunk); |