MyFaces Core
  1. MyFaces Core
  2. MYFACES-3488

[perf] store facelets MARK_CREATED and rendererType at UIComponentBase level

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0.13, 2.1.7
    • Component/s: JSR-314
    • Labels:
      None

      Description

      Inspired on the suggestions done in MYFACES-3470 and MYFACES-3471, I have found a solution for both cases.

      MARK_CREATED and rendererType are special properties. Both are more related to the real UIComponent instance, which means those properties does not change for components inside a table (h:dataTable rowStatePreserved="true").

      In the case of MARK_CREATED, almost all components created by facelets uses it, and this is assigned when the view is built. It has only sense to save this value when the component needs to be restored fully, but since this is a property that does not change once created, it does not have sense to store it on the delta.

      In the case of rendererType, the same as MARK_CREATED happens, but by the spec, it could be valid to set a ValueExpression for it and it is feasible to create a component, call markInitialState() and then call setRendererType(...), so this value could be saved on the delta.

      Components that are created without properties (for example h:panelGroup) only require these two properties, so storing these values at UIComponentBase it is possible to prevent create unnecessary Map.Entry instances.

        Issue Links

          Activity

          Hide
          Leonardo Uribe added a comment -

          The idea with that check lenght first is prevent an unnecessary cast. The number comparison is cheaper compared with the cast, so it is ok to let it as is.

          Show
          Leonardo Uribe added a comment - The idea with that check lenght first is prevent an unnecessary cast. The number comparison is cheaper compared with the cast, so it is ok to let it as is.
          Hide
          Mark Struberg added a comment -

          intern can have mem disadvantages.

          Show
          Mark Struberg added a comment - intern can have mem disadvantages.
          Hide
          Martin Kočí added a comment -

          Good solution!

          Only one question:
          if (MARK_CREATED.length() == ((String)key).length() &&
          MARK_CREATED.equals(key))
          {

          I think String does this length == as first operations in equals():
          String.equals:
          ....
          if (anObject instanceof String) {
          String anotherString = (String)anObject;
          int n = count;
          if (n == anotherString.count) {

          Or can we use advantage of String.intern() and compare with == operator?

          Show
          Martin Kočí added a comment - Good solution! Only one question: if (MARK_CREATED.length() == ((String)key).length() && MARK_CREATED.equals(key)) { I think String does this length == as first operations in equals(): String.equals: .... if (anObject instanceof String) { String anotherString = (String)anObject; int n = count; if (n == anotherString.count) { Or can we use advantage of String.intern() and compare with == operator?

            People

            • Assignee:
              Leonardo Uribe
              Reporter:
              Leonardo Uribe
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development