From: "Enrico Weigelt, metux IT consult" <[email protected]>
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 | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/net/sf/freecol/common/model/ProductionType.java
b/src/net/sf/freecol/common/model/ProductionType.java
index 2911fe78bde..068c96bba17 100644
--- a/src/net/sf/freecol/common/model/ProductionType.java
+++ b/src/net/sf/freecol/common/model/ProductionType.java
@@ -344,11 +344,21 @@ public class ProductionType extends FreeColSpecObject {
*/
public static ProductionType getBestProductionType(GoodsType goodsType,
Collection<ProductionType> types) {
- final Comparator<ProductionType> comp = cachingIntComparator(pt -> {
- AbstractGoods best = pt.getBestOutputFor(goodsType);
- return (best == null) ? Integer.MIN_VALUE : best.getAmount();
- });
- return maximize(types, comp);
+
+ int max_val = 0;
+ ProductionType max_pt = null;
+ for (ProductionType pt : types) {
+ AbstractGoods best = pt.getBestOutputFor(goodsType);
+ if (best == null)
+ continue;
+
+ int x = best.getAmount();
+ if (x > max_val) {
+ max_val = x;
+ max_pt = pt;
+ }
+ }
+ return max_pt;
}
/**
--
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/freecol-developers