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

wasted work in "DefaultGrailsDomainClassInjector.implementsMethod"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0.5
    • 2.0.6, 2.1.0-beta-1
    • None
    • None
    • Patch

    Description

      The problem appears in version 2.0.5 and in revision 4cf5263.. I
      attached a one-line patch that fixes it. I will also post (in the
      "Comments" section) the URL for the github pull request.

      In method "DefaultGrailsDomainClassInjector.implementsMethod", in the
      loop over "methods", the statement
      "boolean methodMatch = mn.getName().equals(methodName) && isZeroArg"
      should be
      "boolean methodMatch = isZeroArg && mn.getName().equals(methodName)".
      The second statement avoids comparing strings when "isZeroArg" is
      "false".

      The code can be made even shorter and faster by having a fast exit (by
      pulling "isZeroArg" out of the loop) at the beginning of the method
      body; this avoids the entire method computation. While the resulting
      code is more compact than the original, the patch itself is a bit
      larger (deletes 3 lines, adds 2). I attached this patch
      (patchFull.diff).

      Attachments

        1. patch.diff
          1.0 kB
        2. patchFull.diff
          1 kB

        Activity

          People

            blackdrag Jochen Theodorou
            adriannistor Adrian Nistor
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: