You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mk...@apache.org on 2003/04/01 21:31:24 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/utils XMLStringDefault.java XMLStringFactoryDefault.java DOMHelper.java FastStringBuffer.java IntStack.java SuballocatedIntVector.java

mkwan       2003/04/01 11:31:24

  Modified:    java/src/org/apache/xml/utils DOMHelper.java
                        FastStringBuffer.java IntStack.java
                        SuballocatedIntVector.java
  Added:       java/src/org/apache/xml/utils XMLStringDefault.java
                        XMLStringFactoryDefault.java
  Log:
  Merging XSLTC_DTM and common serializer to the head
  
  Changes in org.apache.xml.utils.
  
  Revision  Changes    Path
  1.4       +1 -1      xml-xalan/java/src/org/apache/xml/utils/DOMHelper.java
  
  Index: DOMHelper.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/DOMHelper.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DOMHelper.java	30 Jan 2003 18:46:19 -0000	1.3
  +++ DOMHelper.java	1 Apr 2003 19:31:24 -0000	1.4
  @@ -690,7 +690,7 @@
           {
             if ((null != nsInfo)
                     && (nsInfo.m_ancestorHasXMLNSAttrs
  -                      == nsInfo.ANCESTORNOXMLNS))
  +                      == NSInfo.ANCESTORNOXMLNS))
             {
               break;
             }
  
  
  
  1.24      +18 -3     xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java
  
  Index: FastStringBuffer.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/FastStringBuffer.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- FastStringBuffer.java	27 Jan 2003 18:45:15 -0000	1.23
  +++ FastStringBuffer.java	1 Apr 2003 19:31:24 -0000	1.24
  @@ -900,8 +900,18 @@
      */
     public String getString(int start, int length)
     {
  -    return getString(new StringBuffer(length), start >>> m_chunkBits,
  -                     start & m_chunkMask, length).toString();
  +    int startColumn = start & m_chunkMask;
  +    int startChunk = start >>> m_chunkBits;
  +    if (startColumn + length < m_chunkMask && m_innerFSB == null) {
  +      return getOneChunkString(startChunk, startColumn, length);
  +    }
  +    return getString(new StringBuffer(length), startChunk, startColumn,
  +                     length).toString();
  +  }
  +
  +  protected String getOneChunkString(int startChunk, int startColumn,
  +                                     int length) {
  +    return new String(m_array[startChunk], startColumn, length);
     }
   
     /**
  @@ -1008,9 +1018,14 @@
               throws org.xml.sax.SAXException
     {
   
  -    int stop = start + length;
       int startChunk = start >>> m_chunkBits;
       int startColumn = start & m_chunkMask;
  +    if (startColumn + length < m_chunkMask && m_innerFSB == null) {
  +        ch.characters(m_array[startChunk], startColumn, length);
  +        return;
  +    }
  +    
  +    int stop = start + length;
       int stopChunk = stop >>> m_chunkBits;
       int stopColumn = stop & m_chunkMask;
   
  
  
  
  1.9       +3 -3      xml-xalan/java/src/org/apache/xml/utils/IntStack.java
  
  Index: IntStack.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/IntStack.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- IntStack.java	27 Jan 2003 18:45:15 -0000	1.8
  +++ IntStack.java	1 Apr 2003 19:31:24 -0000	1.9
  @@ -132,7 +132,7 @@
      *
      * @return     The object at the top of this stack.
      */
  -  public int pop()
  +  public final int pop()
     {
       return m_map[--m_firstFree];
     }
  @@ -141,7 +141,7 @@
      * Quickly pops a number of items from the stack.
      */
   
  -  public void quickPop(int n)
  +  public final void quickPop(int n)
     {
       m_firstFree -= n;
     }
  @@ -153,7 +153,7 @@
      * @return     the object at the top of this stack.
      * @throws  EmptyStackException  if this stack is empty.
      */
  -  public int peek()
  +  public final int peek()
     {
       try {
         return m_map[m_firstFree - 1];
  
  
  
  1.8       +60 -20    xml-xalan/java/src/org/apache/xml/utils/SuballocatedIntVector.java
  
  Index: SuballocatedIntVector.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/SuballocatedIntVector.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SuballocatedIntVector.java	27 Jan 2003 18:45:15 -0000	1.7
  +++ SuballocatedIntVector.java	1 Apr 2003 19:31:24 -0000	1.8
  @@ -85,8 +85,11 @@
     /** Bitwise addressing (much faster than div/remainder */
     protected int m_SHIFT, m_MASK;
     
  -  /** Number of blocks to (over)allocate by */
  -  protected  int m_numblocks=32;
  +  /** The default number of blocks to (over)allocate by */
  +  protected static final int NUMBLOCKS_DEFAULT = 32;
  +  
  +  /** The number of blocks to (over)allocate by */
  +  protected int m_numblocks = NUMBLOCKS_DEFAULT;
     
     /** Array of arrays of ints          */
     protected int m_map[][];
  @@ -97,6 +100,12 @@
     /** "Shortcut" handle to m_map[0]. Surprisingly helpful for short vectors. */
     protected int m_map0[];
   
  +  /** "Shortcut" handle to most recently added row of m_map.
  +   * Very helpful during construction.
  +   */
  +  protected int m_buildCache[];
  +  protected int m_buildCacheStartIndex;
  +
   
     /**
      * Default constructor.  Note that the default
  @@ -109,34 +118,37 @@
     }
   
     /**
  -   * Construct a IntVector, using the given block size. For
  -   * efficiency, we will round the requested size off to a power of
  -   * two.
  +   * Construct a IntVector, using the given block size and number
  +   * of blocks. For efficiency, we will round the requested size 
  +   * off to a power of two.
      *
      * @param blocksize Size of block to allocate
  +   * @param numblocks Number of blocks to allocate
      * */
  -  public SuballocatedIntVector(int blocksize)
  +  public SuballocatedIntVector(int blocksize, int numblocks)
     {
       //m_blocksize = blocksize;
       for(m_SHIFT=0;0!=(blocksize>>>=1);++m_SHIFT)
         ;
       m_blocksize=1<<m_SHIFT;
       m_MASK=m_blocksize-1;
  -		
  +    m_numblocks = numblocks;
  +    	
       m_map0=new int[m_blocksize];
  -    m_map = new int[m_numblocks][];
  +    m_map = new int[numblocks][];
       m_map[0]=m_map0;
  +    m_buildCache = m_map0;
  +    m_buildCacheStartIndex = 0;
     }
   	
  -  /** We never _did_ use the increasesize parameter, so I'm phasing
  -   * this constructor out.
  +  /** Construct a IntVector, using the given block size and
  +   * the default number of blocks (32).
      *
  -   * @deprecated use SuballocatedIntVector(int)
  -   * @see SuballocatedIntVector(int)
  +   * @param blocksize Size of block to allocate
      * */
  -  public SuballocatedIntVector(int blocksize,int increasesize)
  +  public SuballocatedIntVector(int blocksize)
     {
  -    this(blocksize);
  +    this(blocksize, NUMBLOCKS_DEFAULT);
     }
   
     /**
  @@ -168,10 +180,13 @@
      */
     public  void addElement(int value)
     {
  -    if(m_firstFree<m_blocksize)
  -      m_map0[m_firstFree++]=value;
  -    else
  -    {
  +    int indexRelativeToCache = m_firstFree - m_buildCacheStartIndex;
  +
  +    // Is the new index an index into the cache row of m_map?
  +    if(indexRelativeToCache >= 0 && indexRelativeToCache < m_blocksize) {
  +      m_buildCache[indexRelativeToCache]=value;
  +      ++m_firstFree;
  +    } else {
         // Growing the outer array should be rare. We initialize to a
         // total of m_blocksize squared elements, which at the default
         // size is 4M integers... and we grow by at least that much each
  @@ -194,10 +209,15 @@
   	block=m_map[index]=new int[m_blocksize];
         block[offset]=value;
   
  +      // Cache the current row of m_map.  Next m_blocksize-1
  +      // values added will go to this row.
  +      m_buildCache = block;
  +      m_buildCacheStartIndex = m_firstFree-offset;
  +
         ++m_firstFree;
       }
     }
  -  
  +
     /**
      * Append several int values onto the vector.
      *
  @@ -326,6 +346,8 @@
     public void removeAllElements()
     {
       m_firstFree = 0;
  +    m_buildCache = m_map0;
  +    m_buildCacheStartIndex = 0;
     }
   
     /**
  @@ -549,5 +571,23 @@
       }
       return -1;
     }
  -
  +  
  +  /**
  +   * Return the internal m_map0 array
  +   * @return the m_map0 array
  +   */
  +  public final int[] getMap0()
  +  {
  +    return m_map0;
  +  }
  +  
  +  /**
  +   * Return the m_map double array
  +   * @return the internal map of array of arrays 
  +   */
  +  public final int[][] getMap()
  +  {
  +    return m_map;
  +  }
  +  
   }
  
  
  
  1.2       +838 -0    xml-xalan/java/src/org/apache/xml/utils/XMLStringDefault.java
  
  
  
  
  1.2       +120 -0    xml-xalan/java/src/org/apache/xml/utils/XMLStringFactoryDefault.java
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org