MyFaces Core
  1. MyFaces Core
  2. MYFACES-3130

[PERF] Avoid unnecessary AbstractList$Itr instances

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • 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.

      1. MYFACES-3130-example.patch
        7 kB
        Martin Kočí
      2. UIViewRoot-MYFACES-3130.patch
        3 kB
        Martin Kočí
      3. MYFACES-3130-part2.patch
        14 kB
        Martin Kočí
      There are no Sub-Tasks for this issue.

        Activity

          People

          • Assignee:
            Martin Kočí
            Reporter:
            Martin Kočí
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development