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

[perf] minimize FacesContext.getCurrentInstance() calls part II

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.0.14, 2.1.8
    • JSR-314
    • None

    Description

      It is still possible to minimize even more the number of calls to FacesContext.getCurrentInstance(), just doing some small changes in some methods.

      For example, Application.createComponent(String componentType) has an internal call to FacesContext.getCurrentInstance(), but the variant Application.createComponent(FacesContext context, String componentType, String rendererType) does not, because it can be retrieved from the parameter. Since rendererType can be null according to JSF spec, the result of both methods is equivalent, so it is possible to use the second variant and save one call per component that does not have rendererType.

      Other important place is when EL evaluation occur (FacesCompositeELResolver), FacesContext.getCurrentInstance() is always called, but it is preferred to get the FacesContext from the ELContext first, because a get over a map of 1 or 2 elements will be faster than a ThreadLocal lookup, which is proportional to the number of threads running.

      Attachments

        Activity

          People

            lu4242 Leonardo Uribe
            lu4242 Leonardo Uribe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: