Skip to content

Commit

Permalink
Reuse a single ThreadingDetector instance for all PalettedContainers (#…
Browse files Browse the repository at this point in the history
…14)

We make all instance methods on ThreadingDetector no-op already, so no point in keeping multiple instances around. This saves around 100mb in my ATM10 SP world.
jpenilla authored Aug 31, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 80aa5f8 commit bc3743c
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package ca.spottedleaf.moonrise.mixin.util_threading_detector;

import net.minecraft.util.ThreadingDetector;
import net.minecraft.world.level.chunk.PalettedContainer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(PalettedContainer.class)
abstract class PalettedContainerMixin {
@Unique
private static final ThreadingDetector THREADING_DETECTOR = new ThreadingDetector("PalettedContainer");

/**
* @reason our ThreadingDetectorMixin makes all instance methods no-op, no use in having multiple instances
* @author jpenilla
*/
@Redirect(
method = "<init>*",
at = @At(
value = "NEW",
target = "Lnet/minecraft/util/ThreadingDetector;"
)
)
private static ThreadingDetector threadingDetector(final String name) {
return THREADING_DETECTOR;
}
}
1 change: 1 addition & 0 deletions src/main/resources/moonrise.mixins.json
Original file line number Diff line number Diff line change
@@ -108,6 +108,7 @@
"starlight.world.ChunkSerializerMixin",
"starlight.world.WorldGenRegionMixin",
"util_thread_counts.UtilMixin",
"util_threading_detector.PalettedContainerMixin",
"util_threading_detector.ThreadingDetectorMixin",
"util_time_source.UtilMixin"
],

0 comments on commit bc3743c

Please sign in to comment.