You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Thibault Kruse (JIRA)" <ji...@apache.org> on 2015/09/08 14:57:45 UTC

[jira] [Created] (GROOVY-7583) Unnecessary Instantiation on DefaultGroovyMethods.numberAwareCompareTo

Thibault Kruse created GROOVY-7583:
--------------------------------------

             Summary: Unnecessary Instantiation on DefaultGroovyMethods.numberAwareCompareTo
                 Key: GROOVY-7583
                 URL: https://issues.apache.org/jira/browse/GROOVY-7583
             Project: Groovy
          Issue Type: Improvement
            Reporter: Thibault Kruse


in numberAwareCompareTo() 
{code}
        NumberAwareComparator<Comparable> numberAwareComparator = new NumberAwareComparator<Comparable>();
        return numberAwareComparator.compare(self, other);
{code}

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.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)