Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-5425

ObjectRange doesn't have BigInteger optimisation for size()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.6
    • 1.8.9, 2.0.7, 2.1.1
    • groovy-jdk
    • None

    Description

      The ObjectRange.size() method has optimisations for BigDecimal, Integer and Long, but not BigInteger

      https://github.com/groovy/groovy-core/blob/master/src/main/groovy/lang/ObjectRange.java#L262

      This means that calling:

      (1G..2147483647G).size()
      

      Takes ages

      Could we change:

      } else if (from instanceof BigInteger || to instanceof BigInteger) {
      

      to

      } else if (from instanceof BigDecimal ||
                 to   instanceof BigDecimal ||
                 from instanceof BigInteger ||
                 to   instanceof BigInteger ) {
      

      To catch this?

      Attachments

        Activity

          People

            tim_yates Tim Yates
            tim_yates Tim Yates
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: