Uploaded image for project: 'MyFaces Core'
  1. MyFaces Core
  2. MYFACES-3130

[perf] Avoid unnecessary AbstractList$Itr instances

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.3.0
    • JSR-314
    • None
    • myfaces core trunk

    Description

      Similar issue: MYFACES-3129

      loop from java 5:

      for (Object object: objects)

      creates new instance of AbstractList$Itr, if objects are instance of ArrayList.

      Similar situation is with explicit .iterator() call.

      In my testcases, it is about ~ 100 000 instances per request/response. Creation itself is cheap, but triggers GC lately.

      I suggest to use old index-style for (i = 0; i < childCount; i++) if possible. Are there any rawbacks of index-based iteration?
      Children is List and as implementation detail we know that it is instance of ArrayList.

      Attachments

        1. MYFACES-3130-example.patch
          7 kB
          Martin Kočí
        2. MYFACES-3130-part2.patch
          14 kB
          Martin Kočí
        3. UIViewRoot-MYFACES-3130.patch
          3 kB
          Martin Kočí

        Activity

          People

            tandraschko Thomas Andraschko
            markoc50 Martin Kočí
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: