mkwan       2003/01/31 08:30:17

  Modified:    java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
                        ExpandedNameTable.java
               java/src/org/apache/xml/dtm/ref/sax2dtm Tag: XSLTC_DTM
                        SAX2DTM2.java
  Added:       java/src/org/apache/xml/dtm/ref Tag: XSLTC_DTM
                        ExtendedType.java
  Log:
  Make the nested class ExtendedType in ExpandedNameTable a standalone class.
  Cache the ExtendedType array in SAX2DTM2.
  This change itself has no noticeable performance impact, but it makes other
  optimizations possible. I will make use of this in the coming patches.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.2.8   +21 -77    
xml-xalan/java/src/org/apache/xml/dtm/ref/ExpandedNameTable.java
  
  Index: ExpandedNameTable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/ExpandedNameTable.java,v
  retrieving revision 1.4.2.7
  retrieving revision 1.4.2.8
  diff -u -r1.4.2.7 -r1.4.2.8
  --- ExpandedNameTable.java    30 Jan 2003 18:41:52 -0000      1.4.2.7
  +++ ExpandedNameTable.java    31 Jan 2003 16:30:17 -0000      1.4.2.8
  @@ -239,9 +239,7 @@
      */
     public String getLocalName(int ExpandedNameID)
     {
  -    //return m_locNamesPool.indexToString(ExpandedNameID & MASK_LOCALNAME);
  -    ExtendedType etype = m_extendedTypes[ExpandedNameID];
  -    return etype.localName;
  +    return m_extendedTypes[ExpandedNameID].getLocalName();
     }
   
     /**
  @@ -252,9 +250,8 @@
      */
     public final int getLocalNameID(int ExpandedNameID)
     {
  -    //return (ExpandedNameID & MASK_LOCALNAME);
  -    ExtendedType etype = m_extendedTypes[ExpandedNameID];
  -    if (etype.localName.equals(""))
  +    // ExtendedType etype = m_extendedTypes[ExpandedNameID];
  +    if (m_extendedTypes[ExpandedNameID].getLocalName().equals(""))
         return 0;
       else
       return ExpandedNameID;
  @@ -270,11 +267,8 @@
      */
     public String getNamespace(int ExpandedNameID)
     {
  -
  -    //int id = (ExpandedNameID & MASK_NAMESPACE) >> BITS_PER_LOCALNAME;
  -    //return (0 == id) ? null : m_namespaceNames.indexToString(id);
  -    ExtendedType etype = m_extendedTypes[ExpandedNameID];
  -    return (etype.namespace.equals("") ? null : etype.namespace);
  +    String namespace = m_extendedTypes[ExpandedNameID].getNamespace();
  +    return (namespace.equals("") ? null : namespace);
     }
   
     /**
  @@ -285,9 +279,8 @@
      */
     public final int getNamespaceID(int ExpandedNameID)
     {
  -    //return (ExpandedNameID & MASK_NAMESPACE) >> BITS_PER_LOCALNAME;
  -    ExtendedType etype = m_extendedTypes[ExpandedNameID];
  -    if (etype.namespace.equals(""))
  +    //ExtendedType etype = m_extendedTypes[ExpandedNameID];
  +    if (m_extendedTypes[ExpandedNameID].getNamespace().equals(""))
         return 0;
       else
       return ExpandedNameID;
  @@ -301,77 +294,28 @@
      */
     public final short getType(int ExpandedNameID)
     {
  -    ExtendedType etype = m_extendedTypes[ExpandedNameID];
  -    return (short)etype.nodetype;
  +    //ExtendedType etype = m_extendedTypes[ExpandedNameID];
  +    return (short)m_extendedTypes[ExpandedNameID].getNodeType();
     }
     
  +  /**
  +   * Return the size of the ExpandedNameTable
  +   *
  +   * @return The size of the ExpandedNameTable
  +   */
     public int getSize()
     {
       return m_nextType;
     }
     
  -  
     /**
  -   * Private class representing an extended type object
  +   * Return the array of extended types
  +   *
  +   * @return The array of extended types
      */
  -  private final static class ExtendedType
  +  public ExtendedType[] getExtendedTypes()
     {
  -    protected int nodetype;
  -    protected String namespace;
  -    protected String localName;
  -    protected int hash;
  -
  -    protected ExtendedType (int nodetype, String namespace, String localName)
  -    {
  -      this.nodetype = nodetype;
  -      this.namespace = namespace;
  -      this.localName = localName;
  -      this.hash=nodetype+namespace.hashCode()+localName.hashCode();
  -    }
  -
  -     /* This is intended to be used ONLY on the hashET
  -      * object. Using it elsewhere will mess up existing
  -      * hashtable entries!
  -      * */
  -    protected void redefine(int nodetype, String namespace, String localName)
  -    {
  -      this.nodetype = nodetype;
  -      this.namespace = namespace;
  -      this.localName = localName;
  -      this.hash=nodetype+namespace.hashCode()+localName.hashCode();
  -    }
  -
  -    /* Override super method
  -      * */
  -    public int hashCode()
  -    {
  -     return hash;
  -    }
  -
  -    /* Override super method
  -      * */
  -    public boolean equals(Object other)
  -    {
  -      //Usually an optimization, but
  -      // won't arise in our usage:
  -      //if(other==this) return true;
  -      try
  -      {
  -          ExtendedType et=(ExtendedType)other;
  -          return et.nodetype==this.nodetype &&
  -                  et.localName.equals(this.localName) &&
  -                  et.namespace.equals(this.namespace);
  -      }
  -      catch(ClassCastException e)
  -      {
  -              return false;
  -      }
  -      catch(NullPointerException e)
  -      {
  -              return false;
  -      }
  -    }
  -
  +    return m_extendedTypes;
     }
  -
  -}
  +  
  +}
  \ No newline at end of file
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +145 -0    
xml-xalan/java/src/org/apache/xml/dtm/ref/Attic/ExtendedType.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +8 -3      
xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java
  
  Index: SAX2DTM2.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/sax2dtm/Attic/SAX2DTM2.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- SAX2DTM2.java     29 Jan 2003 22:03:29 -0000      1.1.2.1
  +++ SAX2DTM2.java     31 Jan 2003 16:30:17 -0000      1.1.2.2
  @@ -70,9 +70,9 @@
   /**
    * SAX2DTM2 is an optimized version of SAX2DTM which is used in 
non-incremental case.
    * It is used as the super class of the XSLTC SAXImpl. Many of the 
interfaces in SAX2DTM
  - * and DTMDefaultBase are overrided in SAX2DTM2 in order to provide a fast, 
efficient 
  - * wrapper for the underlying DTM model. Some nested iterators in 
DTMDefaultBaseIterators
  - * are also overrided in SAX2DTM2 for performance reasons.
  + * and DTMDefaultBase are overridden in SAX2DTM2 in order to allow fast, 
efficient 
  + * access to the DTM model. Some nested iterators in DTMDefaultBaseIterators
  + * are also overridden in SAX2DTM2 for performance reasons.
    *
    * %MK% The code in this class is critical to the XSLTC_DTM performance. Be 
very careful
    * when making changes here!
  @@ -1541,6 +1541,9 @@
     private int[][] m_nextsib_map;
     private int[][] m_firstch_map;
     private int[][] m_parent_map;
  +
  +  // %OPT% Cache the array of extended types in this class
  +  private ExtendedType[] m_extendedTypes;
     
     // Cache the shift and mask values for the SuballocatedIntVectors.
     protected final int m_SHIFT;
  @@ -1667,6 +1670,8 @@
       // the end indication.
       m_exptype.addElement(NULL);
       
  +    // Set the cached references after the document is built.
  +    m_extendedTypes = m_expandedNameTable.getExtendedTypes();
       m_exptype_map = m_exptype.getMap();
       m_nextsib_map = m_nextsib.getMap();
       m_firstch_map = m_firstch.getMap();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to