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

SC: optimize for-in loop on array with dynamic variable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.5.16, 3.0.10, 4.0.1
    • None
    • None

    Description

      Consider the following:

      @groovy.transform.CompileStatic
      void test(String[] strings) {
        for (string in strings) {
          // ...
        }
      }
      

      This code does not write an optimized array-based iteration since the type of "string" isn't explicitly declared. "for (String string in strings)" and "for (String string : strings)" are so optimized.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: