groovy/groovy-core — pull request #217 by adriannistor (2013-07-16 15:00:37+00:00)
Title: Inefficient method DefaultGrailsDomainClassInjector.implementsMethod

The problem appears in versions 2.1.6, 2.2.0-beta-1 and in revision
ca83beb. This is a simple patch to fix it. The patch moves only one
line, but it looks larger because I indented the loop to preserve
formatting. I also reported this problem and sent a patch at
http://jira.codehaus.org/browse/GROOVY-6261.

In method "DefaultGrailsDomainClassInjector.implementsMethod", the
loop over "methods" should not be executed when
"(argTypes == null || argTypes.length ==0)" is false. When
"(argTypes == null || argTypes.length ==0)" is false, "isZeroArg" is
false, which makes "methodMatch" false, which means the loop will not
execute "return true". "return true" is the loop's only side effect,
so when "return true" cannot be executed, the loop is not necessary.
Note that "argTypes" and "argTypes.length" are never modified in the
loop, so the value of "(argTypes == null || argTypes.length ==0)" does
not change during the loop execution.