You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by hi...@apache.org on 2001/01/03 11:12:02 UTC

cvs commit: xml-batik/sources/org/apache/batik/dom/util DocumentFactory.java HashTable.java

hillion     01/01/03 02:12:02

  Modified:    sources/org/apache/batik/dom AbstractElement.java
               sources/org/apache/batik/dom/util DocumentFactory.java
                        HashTable.java
  Log:
  DOM tuning.
  
  Revision  Changes    Path
  1.7       +3 -3      xml-batik/sources/org/apache/batik/dom/AbstractElement.java
  
  Index: AbstractElement.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractElement.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractElement.java	2001/01/02 07:02:30	1.6
  +++ AbstractElement.java	2001/01/03 10:12:01	1.7
  @@ -29,7 +29,7 @@
    * This class implements the {@link org.w3c.dom.Element} interface.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: AbstractElement.java,v 1.6 2001/01/02 07:02:30 hillion Exp $
  + * @version $Id: AbstractElement.java,v 1.7 2001/01/03 10:12:01 hillion Exp $
    */
   public abstract class AbstractElement
       extends    AbstractParentChildNode
  @@ -510,7 +510,7 @@
   	/**
   	 * The place where the nodes in the anonymous namespace are stored.
   	 */
  -	protected HashTable table = new HashTable();
  +	protected HashTable table = new HashTable(3);
   
   	/**
   	 * The place where the the nodes that use namespaces are stored.
  @@ -651,7 +651,7 @@
   	    checkNode(arg);
   
   	    if (tableNS == null) {
  -		tableNS = new HashTable();
  +		tableNS = new HashTable(3);
   	    }
   	    NamedNodeHashMap attr = (NamedNodeHashMap)tableNS.get(nsURI);
   	    if (attr == null) {
  
  
  
  1.4       +2 -2      xml-batik/sources/org/apache/batik/dom/util/DocumentFactory.java
  
  Index: DocumentFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/util/DocumentFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DocumentFactory.java	2001/01/02 16:11:52	1.3
  +++ DocumentFactory.java	2001/01/03 10:12:01	1.4
  @@ -30,7 +30,7 @@
    * from an URI using SAX2.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: DocumentFactory.java,v 1.3 2001/01/02 16:11:52 hillion Exp $
  + * @version $Id: DocumentFactory.java,v 1.4 2001/01/03 10:12:01 hillion Exp $
    */
   public class DocumentFactory
       extends    DefaultHandler
  @@ -174,7 +174,7 @@
   	    if (idx != -1 && idx != rawName.length()-1) {
   		lname = rawName.substring(idx+1);
   	    }
  -	    if (e.getNamespaceURI() != null) {
  +	    if (e.getNamespaceURI() != null && nsp.length() != 0) {
   		if (!e.getLocalName().equals(lname)) {
   		    throw new SAXException("Bad root element");
   		}
  
  
  
  1.3       +16 -18    xml-batik/sources/org/apache/batik/dom/util/HashTable.java
  
  Index: HashTable.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/util/HashTable.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- HashTable.java	2000/11/15 15:17:58	1.2
  +++ HashTable.java	2001/01/03 10:12:01	1.3
  @@ -14,14 +14,10 @@
    * A simple hashtable, not synchronized, with fixed load factor.
    *
    * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
  - * @version $Id: HashTable.java,v 1.2 2000/11/15 15:17:58 hillion Exp $
  + * @version $Id: HashTable.java,v 1.3 2001/01/03 10:12:01 hillion Exp $
    */
   
   public class HashTable implements Serializable {
  -    /**
  -     * The load factor
  -     */
  -    protected final static float LOAD_FACTOR = 0.75f;
   	    
       /**
        * The initial capacity
  @@ -39,16 +35,18 @@
       protected int count;
   	    
       /**
  -     * The resizing threshold
  +     * Creates a new table.
        */
  -    protected int threshold;
  -	    
  +    public HashTable() {
  +	table = new Entry[INITIAL_CAPACITY];
  +    }
  +
       /**
        * Creates a new table.
  +     * @param c The initial capacity.
        */
  -    public HashTable() {
  -	table     = new Entry[INITIAL_CAPACITY];
  -	threshold = (int)(INITIAL_CAPACITY * LOAD_FACTOR);
  +    public HashTable(int c) {
  +	table = new Entry[c];
       }
   
       /**
  @@ -56,7 +54,6 @@
        * @param t The table to copy.
        */
       public HashTable(HashTable t) {
  -	threshold = t.threshold;
   	count = t.count;
   	table = new Entry[t.table.length];
   	for (int i = 0; i < table.length; i++) {
  @@ -115,7 +112,8 @@
   	}
   	
   	// The key is not in the hash table
  -	if (count++ >= threshold) {
  +        int len = table.length;
  +	if (count++ >= (len * 3) >>> 2) {
   	    rehash();
   	    index = hash % table.length;
   	}
  @@ -200,9 +198,10 @@
        * Clears the map.
        */
       public void clear() {
  -	table     = new Entry[INITIAL_CAPACITY];
  -	threshold = (int)(INITIAL_CAPACITY * LOAD_FACTOR);
  -	count     = 0;
  +        for (int i = 0; i < table.length; i++) {
  +            table[i] = null;
  +        }
  +	count = 0;
       }
   
       /**
  @@ -211,8 +210,7 @@
       protected void rehash () {
   	Entry[] oldTable = table;
   	
  -	table     = new Entry[oldTable.length * 2 + 1];
  -	threshold = (int)(table.length * LOAD_FACTOR);
  +	table = new Entry[oldTable.length * 2 + 1];
   	
   	for (int i = oldTable.length-1; i >= 0; i--) {
   	    for (Entry old = oldTable[i]; old != null;) {