From 71971a01ca9ff09d220a49970255069a8efe0046 Mon Sep 17 00:00:00 2001 From: AlexIIL Date: Wed, 25 Dec 2019 13:01:21 +0000 Subject: Optimise EntryRegistryImpl.registerEntries by first checking in a set to see if the given entry already exists before adding it, instead of looping through the whole list to see if any of them match. --- src/main/java/me/shedaniel/rei/api/EntryRegistry.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main/java/me/shedaniel/rei/api/EntryRegistry.java') diff --git a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java index 1a8c5f157..a7765036d 100644 --- a/src/main/java/me/shedaniel/rei/api/EntryRegistry.java +++ b/src/main/java/me/shedaniel/rei/api/EntryRegistry.java @@ -10,6 +10,7 @@ import me.shedaniel.rei.utils.CollectionUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import java.util.Collection; import java.util.List; public interface EntryRegistry { @@ -72,6 +73,16 @@ public interface EntryRegistry { } } + /** + * Registers multiple stacks to the item list + * + * @param afterStack the stack to put after + * @param stacks the stacks to register + */ + default void registerEntriesAfter(EntryStack afterStack, Collection stacks) { + registerEntriesAfter(afterStack, stacks.toArray(new EntryStack[0])); + } + /** * Registers multiple stacks to the item list * -- cgit