axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/message SymbolTable.java
Date Sun, 15 Jul 2001 18:12:41 GMT
gdaniels    01/07/15 11:12:41

  Modified:    java/src/org/apache/axis/message SymbolTable.java
  Log:
  Though it could still use reworking, this version noticeably increases
  performance (getting rid of the linear search for each symbol addition)
  at the cost of maintaining a HashMap in addition to the ArrayList.
  
  Revision  Changes    Path
  1.4       +9 -4      xml-axis/java/src/org/apache/axis/message/SymbolTable.java
  
  Index: SymbolTable.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SymbolTable.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SymbolTable.java	2001/07/15 17:42:42	1.3
  +++ SymbolTable.java	2001/07/15 18:12:40	1.4
  @@ -1,6 +1,6 @@
   package org.apache.axis.message;
   
  -import java.util.ArrayList;
  +import java.util.*;
   
   /**
    * This was swiped from xerces2, I stripped the comments
  @@ -13,7 +13,8 @@
       protected Entry[] fBuckets = new Entry[TABLE_SIZE];
       public SymbolTable() {}
       
  -    public ArrayList list = new ArrayList();
  +    private ArrayList list = new ArrayList();
  +    private HashMap hash = new HashMap();
       
       public String getSymbol(int bucket) {
           return (String)list.get(bucket);
  @@ -23,10 +24,14 @@
       }
       
       public int addSymbol(String symbol) {
  -        int ret = list.indexOf(symbol);
  -        if (ret == -1) {
  +        Integer i = (Integer)hash.get(symbol);
  +        int ret;
  +        if (i == null) {
               list.add(symbol);
               ret = list.size() - 1;
  +            hash.put(symbol, new Integer(ret));
  +        } else {
  +            ret = i.intValue();
           }
           return ret;
           /*
  
  
  

Mime
View raw message