diff options
author | Jason Mitchell <mitchej@gmail.com> | 2021-01-05 19:51:58 -0800 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2021-01-05 19:51:58 -0800 |
commit | 083d45487ef5419483eb2d654e3ce17d240af835 (patch) | |
tree | f171b929abb754643b3e22f673bc211dd932940a /src/main/java | |
parent | 3b6bc659ee5a38644ce0c3e55dbc3363e3a7100e (diff) | |
download | GT5-Unofficial-083d45487ef5419483eb2d654e3ce17d240af835.tar.gz GT5-Unofficial-083d45487ef5419483eb2d654e3ce17d240af835.tar.bz2 GT5-Unofficial-083d45487ef5419483eb2d654e3ce17d240af835.zip |
Speed up removals even more
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/gregtech/GT_Mod.java | 2 | ||||
-rw-r--r-- | src/main/java/gregtech/api/util/GT_ModHandler.java | 24 |
2 files changed, 17 insertions, 9 deletions
diff --git a/src/main/java/gregtech/GT_Mod.java b/src/main/java/gregtech/GT_Mod.java index 62148430b5..45a152a98c 100644 --- a/src/main/java/gregtech/GT_Mod.java +++ b/src/main/java/gregtech/GT_Mod.java @@ -857,7 +857,7 @@ public class GT_Mod implements IGT_Mod { }); } ProgressManager.pop(progressBar); - GT_FML_LOGGER.info("Congratulations, you have been waiting long enough (" + stopwatch.stop() + "). Have a Cake."); + GT_FML_LOGGER.info("Replaced Vanilla Materials (" + stopwatch.stop() + "). Have a Cake."); stopwatch.reset(); diff --git a/src/main/java/gregtech/api/util/GT_ModHandler.java b/src/main/java/gregtech/api/util/GT_ModHandler.java index e8d311da39..484e4d29b9 100644 --- a/src/main/java/gregtech/api/util/GT_ModHandler.java +++ b/src/main/java/gregtech/api/util/GT_ModHandler.java @@ -61,6 +61,7 @@ import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import static gregtech.GT_Mod.GT_FML_LOGGER; import static gregtech.api.enums.GT_Values.B; import static gregtech.api.enums.GT_Values.D1; import static gregtech.api.enums.GT_Values.DW; @@ -154,7 +155,7 @@ public class GT_ModHandler { public static List<Integer> sSingleNonBlockDamagableRecipeList_warntOutput = new ArrayList<>(50); public static List<Integer> sVanillaRecipeList_warntOutput = new ArrayList<>(50); public static final List<IRecipe> sSingleNonBlockDamagableRecipeList_verified = new ArrayList<>(1000); - private static Cache<GT_ItemStack, ItemStack> sSmeltingRecipeCache = CacheBuilder.newBuilder().maximumSize(1000).build(); + private static final Cache<GT_ItemStack, ItemStack> sSmeltingRecipeCache = CacheBuilder.newBuilder().maximumSize(1000).build(); public static List<Integer> sAnySteamFluidIDs = new ArrayList<>(); public static List<Integer> sSuperHeatedSteamFluidIDs = new ArrayList<>(); @@ -1333,11 +1334,14 @@ public class GT_ModHandler { public static void bulkRemoveByRecipe(List<InventoryCrafting> toRemove) { ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); + GT_FML_LOGGER.info("BulkRemoveByRecipe: tList: " + tList.size() + " toRemove: " + toRemove.size() ); - tList.removeIf(tRecipe -> { + Set<IRecipe> tListToRemove = tList.parallelStream().filter(tRecipe -> { if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) return false; - return toRemove.stream().anyMatch(aCrafting -> tRecipe.matches(aCrafting, DW)); - }); + return toRemove.stream().anyMatch(aCrafting -> tRecipe.matches(aCrafting, DW)); + }).collect(Collectors.toSet()); + + tList.removeIf(tListToRemove::contains); } public static boolean removeRecipeByOutputDelayed(ItemStack aOutput) { @@ -1395,14 +1399,18 @@ public class GT_ModHandler { public static boolean bulkRemoveRecipeByOutput(List<ItemStack> toRemove) { ArrayList<IRecipe> tList = (ArrayList<IRecipe>) CraftingManager.getInstance().getRecipeList(); - Set<ItemStack> setToRemove = toRemove.stream().map(GT_OreDictUnificator::get_nocopy).collect(Collectors.toSet()); - - tList.removeIf(tRecipe -> { + Set<ItemStack> setToRemove = toRemove.parallelStream().map(GT_OreDictUnificator::get_nocopy).collect(Collectors.toSet()); + + GT_FML_LOGGER.info("BulkRemoveRecipeByOutput: tList: " + tList.size() + " setToRemove: " + setToRemove.size() ); + + Set<IRecipe> tListToRemove = tList.parallelStream().filter(tRecipe -> { if ((tRecipe instanceof IGT_CraftingRecipe) && !((IGT_CraftingRecipe) tRecipe).isRemovable()) return false; if (sSpecialRecipeClasses.contains(tRecipe.getClass().getName())) return false; final ItemStack tStack = GT_OreDictUnificator.get_nocopy(tRecipe.getRecipeOutput()); return setToRemove.stream().anyMatch(aOutput -> GT_Utility.areStacksEqual(tStack, aOutput, true)); - }); + }).collect(Collectors.toSet()); + + tList.removeIf(tListToRemove::contains); return true; } |