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

Unnecessary Instantiation on DefaultGroovyMethods.numberAwareCompareTo

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.5
    • 2.4.6
    • None
    • None

    Description

      in numberAwareCompareTo()

              NumberAwareComparator<Comparable> numberAwareComparator = new NumberAwareComparator<Comparable>();
              return numberAwareComparator.compare(self, other);
      

      The code inside NumberAwareComparator.compare can be static, so there is no need to create a new Instance of the Comparator every numberAwareCompareTo is called. I suggest extracting the logic into a public static method, and to use that, or anything similar.

      Attachments

        Activity

          People

            pascalschumacher Pascal Schumacher
            tkruse Thibault Kruse
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: