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

ObjectRange doesn't have BigInteger optimisation for size()

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.6
    • Fix Version/s: 1.8.9, 2.0.7, 2.1.1
    • Component/s: groovy-jdk
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: