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

Inefficient method DefaultGrailsDomainClassInjector.implementsMethod(..)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.6, 2.2.0-beta-1
    • Fix Version/s: 2.2.0-beta-2
    • Component/s: None
    • Labels:
    • Flags:
      Patch

      Description

      The problem appears in versions 2.1.6, 2.2.0-beta-1 and in revision ca83beb.

      I attached a simple patch that fixes it.

      The patch moves only one line, but it looks larger because I indented the loop to preserve formatting.

      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.

        Attachments

        1. patch.diff
          1 kB

          Activity

            People

            • Assignee:
              pschumacher Pascal Schumacher
              Reporter:
              adriannistor Adrian Nistor
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: