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.