Skip to content

Commit

Permalink
Improve performance of LOreDict::mergeFuzzy
Browse files Browse the repository at this point in the history
  • Loading branch information
Fybe committed Oct 29, 2023
1 parent 80e8f5d commit a27e33c
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.function.BiPredicate;
Expand Down Expand Up @@ -69,9 +70,13 @@ public static boolean mergeFuzzy(ILabel a, ILabel b) {
if (a instanceof LOreDict && b instanceof LItemStack) {
LOreDict lod = (LOreDict) a;
LItemStack lis = (LItemStack) b;
return lod.getAmount() * lis.getAmount() < 0
&& OreDictionary.getOres(lod.name).stream().map(Converter::from)
.anyMatch(i -> LItemStack.merge(i, lis));
if (lod.getAmount() * lis.getAmount() >= 0)
return false;

int[] oreIDs = OreDictionary.getOreIDs(lis.getRep());
return Arrays.stream(oreIDs)
.mapToObj(OreDictionary::getOreName)
.anyMatch(ore -> ore.equals(lod.getName()));
}
return false;
}
Expand Down

0 comments on commit a27e33c

Please sign in to comment.