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

Unnecessary Instantiation on DefaultGroovyMethods.numberAwareCompareTo

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.4.5
    • Fix Version/s: 2.4.6
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: