You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/08/21 09:24:07 UTC

[groovy] 07/11: Use BigDecimal.valueOf()

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 5dffd3840ed30b20e600fa960c7e776fab4a98c1
Author: Bo Zhang <zh...@gmail.com>
AuthorDate: Sat Aug 17 19:25:30 2019 +0800

    Use BigDecimal.valueOf()
---
 src/main/java/groovy/lang/ObjectRange.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/groovy/lang/ObjectRange.java b/src/main/java/groovy/lang/ObjectRange.java
index a7e2b05..b78b193 100644
--- a/src/main/java/groovy/lang/ObjectRange.java
+++ b/src/main/java/groovy/lang/ObjectRange.java
@@ -302,7 +302,7 @@ public class ObjectRange extends AbstractList<Comparable> implements Range<Compa
                 // let's fast calculate the size
                 final BigDecimal fromNum = new BigDecimal(from.toString());
                 final BigDecimal toNum = new BigDecimal(to.toString());
-                final BigInteger sizeNum = toNum.subtract(fromNum).add(new BigDecimal(1.0)).toBigInteger();
+                final BigInteger sizeNum = toNum.subtract(fromNum).add(BigDecimal.valueOf(1.0)).toBigInteger();
                 tempsize = sizeNum.intValue();
                 if (!BigInteger.valueOf(tempsize).equals(sizeNum)) {
                     tempsize = Integer.MAX_VALUE;