You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/11/13 20:39:16 UTC

DO NOT REPLY [Bug 14522] New: - Performance problem due to unnecessary ArrayIndexOutOfBoundsException

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14522>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14522

Performance problem due to unnecessary ArrayIndexOutOfBoundsException

           Summary: Performance problem due to unnecessary
                    ArrayIndexOutOfBoundsException
           Product: XalanJ2
           Version: CurrentCVS
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: org.apache.xml.dtm
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: dminard@objectiveEdge.com


The latest version of DTMManagerDefault.getDTM() checks for a DTM.NULL argument 
*after* catching an ArrayIndexOutOfBoundsException instead of *before*.  The in-
line comment indicates this function is performance critical.  OptimizeIt 
indicates that the performance of the current implementation suffers because of 
the unnecessary creation of ArrayIndexOutOfBoundsException objects.


Instead of

BEGIN CURRENT CODE
-------------------
synchronized public DTM DTMManagerDefault.getDTM(int nodeHandle)
{
  try
  {
    // Performance critical function
    return m_dtms[nodeHandle >>> IDENT_DTM_NODE_BITS];
  }
  catch (java.lang.ArrayIndexOutOfBoundsException e)
  {
    if (nodeHandle == DTM.NULL)
        return null; // Accept as a special case
    else
      throw e; // Programming error; want to know about it
  }
}

----------------
END CURRENT CODE




BEGIN SUGGESTED CODE
-------------------
synchronized public DTM DTMManagerDefault.getDTM(int nodeHandle)
{
  if (nodeHandle == DTM.NULL)
      return null; // Accept as a special case

  // Performance critical function
  return m_dtms[nodeHandle >>> IDENT_DTM_NODE_BITS];
}
----------------
END SUGGESTED CODE