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

performance issue with collections operations when numbers are elements of the collections

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.5, 1.5.1
    • 1.5.2, 1.6-rc-2
    • groovy-jdk
    • None
    • Patch

    Description

      In DefaultGroovyMethods.java, a NumberAwareComparator mimics the groovy '==' operator to compare elements against each other for collections operations such as unique(), minus(), sort() etc.
      This NumberAwareComparator systematically converts any number to BigDecimal if numbers are involved slowing down very significantly those operations.
      By testing first if the elements are comparable and of the same 'kind' to first compareTo() them, we get a cheap but noticeable boost.

      Attachments

        1. coco.patch
          0.6 kB
          Olivier Nenert

        Activity

          People

            blackdrag Jochen Theodorou
            oli4 Olivier Nenert
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: