From: "Enrico Weigelt, metux IT consult" <enrico.weig...@gr13.net>
Dont need the overhead of stream operations with locally allocated comparator object - just scan over the list and find the max. --- src/net/sf/freecol/common/model/ProductionType.java | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/net/sf/freecol/common/model/ProductionType.java b/src/net/sf/freecol/common/model/ProductionType.java index 068c96bba17..58d1469f5db 100644 --- a/src/net/sf/freecol/common/model/ProductionType.java +++ b/src/net/sf/freecol/common/model/ProductionType.java @@ -24,7 +24,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.function.Predicate; import javax.xml.stream.XMLStreamException; @@ -368,10 +367,22 @@ public class ProductionType extends FreeColSpecObject { * @return The best production. */ public AbstractGoods getBestOutputFor(GoodsType goodsType) { - final Predicate<AbstractGoods> typePred = ag -> - goodsType == null || ag.getType() == goodsType; - return maximize(getOutputs(), typePred, - AbstractGoods.ascendingAmountComparator); + if (outputs == null) + return null; + + int max_amount = 0; + AbstractGoods max_ag = null; + for (AbstractGoods walk : outputs) { + if (goodsType == null || walk.getType() == goodsType) { + int a = walk.getAmount(); + if (max_ag == null || a > max_amount) { + max_amount = a; + max_ag = walk; + } + } + } + + return max_ag; } -- 2.11.0.rc0.7.gbe5a750 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Freecol-developers mailing list Freecol-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freecol-developers