From 3a4d385560eb40a13fdc86e01263d4b49a04cedc Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Tue, 27 Oct 2020 11:11:35 +0200 Subject: [PATCH] avoid casting to int when comparing longs --- drongo | 2 +- .../com/sparrowwallet/sparrow/control/UtxosChart.java | 2 +- .../sparrowwallet/sparrow/wallet/HashIndexEntry.java | 2 +- .../sparrowwallet/sparrow/wallet/TransactionEntry.java | 6 +++--- ~/.sparrow-peak/config | 10 ++++++++++ 5 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 ~/.sparrow-peak/config diff --git a/drongo b/drongo index 401d3b8b..67c76c3b 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 401d3b8bfbffb8396a4d76737b4d335389b60051 +Subproject commit 67c76c3b28158e38dbf6a5a3eb49f4a03b01b7b1 diff --git a/src/main/java/com/sparrowwallet/sparrow/control/UtxosChart.java b/src/main/java/com/sparrowwallet/sparrow/control/UtxosChart.java index 483d8eeb..7f3f9dfb 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/UtxosChart.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/UtxosChart.java @@ -39,7 +39,7 @@ public class UtxosChart extends BarChart { public void update(WalletUtxosEntry walletUtxosEntry) { List> utxoDataList = walletUtxosEntry.getChildren().stream() .map(entry -> new XYChart.Data<>(getCategoryName(entry), (Number)entry.getValue(), entry)) - .sorted((o1, o2) -> (int) (o2.getYValue().longValue() - o1.getYValue().longValue())) + .sorted((o1, o2) -> Long.compare(o2.getYValue().longValue(), o1.getYValue().longValue())) .collect(Collectors.toList()); totalUtxos = utxoDataList.size(); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/HashIndexEntry.java b/src/main/java/com/sparrowwallet/sparrow/wallet/HashIndexEntry.java index 6f0a856b..0d2fda4b 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/HashIndexEntry.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/HashIndexEntry.java @@ -101,6 +101,6 @@ public class HashIndexEntry extends Entry implements Comparable return o.getHashIndex().getComparisonHeight() - getHashIndex().getComparisonHeight(); } - return (int)o.getHashIndex().getIndex() - (int)getHashIndex().getIndex(); + return Long.compare(o.getHashIndex().getIndex(), (int)getHashIndex().getIndex()); } } diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionEntry.java b/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionEntry.java index 33fab47f..db93fab4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionEntry.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/TransactionEntry.java @@ -97,15 +97,15 @@ public class TransactionEntry extends Entry implements Comparable