Disable class info clearing by default and only clear non-mixin entries

This commit is contained in:
embeddedt 2023-04-18 22:24:48 -04:00
parent 74c3f0ff90
commit f27d94cf26
No known key found for this signature in database
GPG Key ID: A69433EC199B5613
2 changed files with 5 additions and 1 deletions

View File

@ -42,6 +42,7 @@ public class ModernFixEarlyConfig {
this.addMixinRule("perf.state_definition_construct", modPresent("ferritecore"));
this.addMixinRule("perf.cache_strongholds", true);
this.addMixinRule("perf.dedup_blockstate_flattening_map", false);
this.addMixinRule("perf.clear_mixin_classinfo", false);
this.addMixinRule("perf.cache_upgraded_structures", true);
this.addMixinRule("perf.biome_zoomer", true);
this.addMixinRule("perf.compress_blockstate", false);

View File

@ -1,5 +1,6 @@
package org.embeddedt.modernfix.util;
import org.embeddedt.modernfix.core.ModernFixMixinPlugin;
import org.spongepowered.asm.mixin.transformer.ClassInfo;
import java.lang.reflect.Field;
@ -9,6 +10,8 @@ import java.util.Map;
public class ClassInfoManager {
private static Map<String, ClassInfo> classInfoCache = null;
public static void clear() {
if(!ModernFixMixinPlugin.instance.isOptionEnabled("perf.clear_mixin_classinfo.ClassInfoManager"))
return;
if(classInfoCache == null) {
try {
Field field = ClassInfo.class.getDeclaredField("cache");
@ -20,7 +23,7 @@ public class ClassInfoManager {
}
}
try {
classInfoCache.entrySet().removeIf(entry -> !entry.getKey().equals("java/lang/Object"));
classInfoCache.entrySet().removeIf(entry -> !entry.getKey().equals("java/lang/Object") && (entry.getValue() == null || !entry.getValue().isMixin()));
} catch(RuntimeException e) {
e.printStackTrace();
}