Skip to content

Commit

Permalink
Reuse a single ThreadingDetector instance for all PalettedContainers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jpenilla committed Aug 30, 2024
1 parent 80aa5f8 commit bbd382d
Show file tree
Hide file tree
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
Expand Up @@ -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"
],
Expand Down

0 comments on commit bbd382d

Please sign in to comment.