Pre-size the top level model location set to reduce rehashing

This commit is contained in:
embeddedt 2025-05-09 22:17:36 -04:00
parent 2535174e00
commit 900e5786b6
No known key found for this signature in database
GPG Key ID: A69433EC199B5613

View File

@ -12,6 +12,7 @@ import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
@ -59,7 +60,7 @@ public class ModelBakeEventHelper {
private final MutableGraph<String> dependencyGraph;
public ModelBakeEventHelper(Map<ResourceLocation, BakedModel> modelRegistry) {
this.modelRegistry = modelRegistry;
this.topLevelModelLocations = new ObjectLinkedOpenHashSet<>();
this.topLevelModelLocations = new ObjectLinkedOpenHashSet<>(Block.BLOCK_STATE_REGISTRY.size() + BuiltInRegistries.ITEM.size());
// Skip going through ModelLocationCache because most of the accesses will be misses
BuiltInRegistries.BLOCK.entrySet().forEach(entry -> {
var location = entry.getKey().location();