Skip to content

Commit 3d14045

Browse files
committed
Use classified ingredient maps to optimize recipe index
Closes #160
1 parent e030e78 commit 3d14045

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/java/org/cyclops/integratedcrafting/core/RecipeIndexDefault.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.cyclops.cyclopscore.datastructure.MultitransformIterator;
1010
import org.cyclops.cyclopscore.ingredient.collection.IIngredientMapMutable;
1111
import org.cyclops.cyclopscore.ingredient.collection.IngredientHashMap;
12+
import org.cyclops.cyclopscore.ingredient.collection.IngredientMapSingleClassified;
1213
import org.cyclops.integratedcrafting.api.recipe.IRecipeIndex;
1314
import org.cyclops.integratedcrafting.api.recipe.IRecipeIndexModifiable;
1415

@@ -50,7 +51,11 @@ public <T, M> Iterator<IRecipeDefinition> getRecipes(IngredientComponent<T, M> o
5051

5152
@Nullable
5253
protected <T, M> IIngredientMapMutable<T, M, Set<IRecipeDefinition>> initializeIndex(IngredientComponent<T, M> recipeComponent) {
53-
return new IngredientHashMap<>(recipeComponent);
54+
// TODO: Consider moving/copying this logic to IngredientCollectionHelpers in next/major
55+
if (recipeComponent.getCategoryTypes().size() == 1) {
56+
return new IngredientHashMap<>(recipeComponent);
57+
}
58+
return new IngredientMapSingleClassified<>(recipeComponent, () -> new IngredientHashMap<>(recipeComponent), recipeComponent.getCategoryTypes().get(0));
5459
}
5560

5661
@Override

0 commit comments

Comments
 (0)