UIXComponentBase ::invokeOnComponent should be optimized to avoid calls to 
getClientId
--------------------------------------------------------------------------------------

                 Key: TRINIDAD-1805
                 URL: https://issues.apache.org/jira/browse/TRINIDAD-1805
             Project: MyFaces Trinidad
          Issue Type: Bug
          Components: Components
            Reporter: Stevan Malesevic


UIXComponentBase ::invokeOnComponent is very expensive method and most of the 
cost comes from calls to getClientIds. The code can be optimized to avoid 
number of these calls

1. Before calling getClientId the code should do getId() and compare if passed 
in clientId ends with id
2. If this comp is naming container and its id is not part of passed in 
clientId then clientId is not under this container so skip 
invokeOnChildrenComponents

So code might look like this

  @Override
  public boolean invokeOnComponent(
    FacesContext context,
    String clientId,
    ContextCallback callback)
    throws FacesException
  {
    boolean invokedComponent;
    
    // set up the context for visiting the children
    setupVisitingContext(context);

    try
    {
      //Check if pass in clientId ends with this id
      //If not there is no matching
      String id = this.getId();
      
      if (clientId.endsWith(id)  &&  clientId.equals(getClientId(context)))
      {
        pushComponentToEL(context, null);

        try
        {
          // this is the component we want, so invoke the callback
          callback.invokeContextCallback(context, this);
        }
        finally
        {
          popComponentFromEL(context);
        }

        // we found the component
        invokedComponent = true;
      }
      else
      {
        //if this is naming container and passed in ClientId doesn't containe 
this id
        //then there can not be a match on chiled comps
        if ((this instanceof NamingContainer) && !(clientId.contains(id)))
          invokedComponent = false;
        else
        // set up the children visiting context to iterate through children. We 
inline this
        // code instead of calling super in order
        // to avoid making an extra call to getClientId().
         invokedComponent = invokeOnChildrenComponents(context, clientId, 
callback);
      }
    }
    finally
    {
      // teardown the context now that we have visited the component
      tearDownVisitingContext(context);      
    }

    return invokedComponent;
  }


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to