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

[perf] Avoid unnecessary AbstractList$Itr instances

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.3.0
    • Component/s: JSR-314
    • Labels:
      None
    • Environment:
      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

            • Assignee:
              tandraschko Thomas Andraschko
              Reporter:
              markoc50 Martin Kočí
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: