axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/utils NSStack.java
Date Tue, 12 Jun 2001 12:32:57 GMT
rubys       01/06/12 05:32:57

  Modified:    java/src/org/apache/axis/utils NSStack.java
  Log:
  Performance improvements: reduce the numbers of hashtables created,
  and the number of calls to "contains".
  
  Revision  Changes    Path
  1.4       +15 -5     xml-axis/java/src/org/apache/axis/utils/NSStack.java
  
  Index: NSStack.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/NSStack.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NSStack.java	2001/06/06 15:54:17	1.3
  +++ NSStack.java	2001/06/12 12:32:56	1.4
  @@ -65,6 +65,8 @@
   public class NSStack { 
       private static final boolean DEBUG_LOG = false;
       
  +    private static final Hashtable EMPTY = new Hashtable();
  +
       private Stack stack = new Stack();
       
       private NSStack parent = null;
  @@ -83,14 +85,17 @@
           if (stack == null) stack = new Stack();
           if (DEBUG_LOG)
               System.out.println("NSPush (" + stack.size() + ")");
  -        stack.push(new Hashtable());
  +        stack.push(EMPTY);
       }
       
       public void push(Hashtable table) {
           if (stack == null) stack = new Stack();
           if (DEBUG_LOG)
               System.out.println("NSPush (" + stack.size() + ")");
  -        stack.push(table);
  +        if (table.size() == 0) 
  +           stack.push(EMPTY);
  +        else
  +           stack.push(table);
       }
       
       public Hashtable peek() {
  @@ -125,6 +130,11 @@
       public void add(String namespaceURI, String prefix) {
           if (stack.isEmpty()) push();
           Hashtable table = peek();
  +        if (table == EMPTY) {
  +            table = new Hashtable();
  +            stack.pop();
  +            stack.push(table);
  +        }
           table.put(namespaceURI, prefix);
       }
       
  @@ -141,7 +151,7 @@
               for (int n = stack.size() - 1; n >= 0; n--) {
                   Hashtable t = (Hashtable)stack.elementAt(n);
                   
  -                if ((t != null) && t.containsKey(namespaceURI)) 
  +                if ((t != null) && (t != EMPTY) && t.containsKey(namespaceURI))

                       return (String)t.get(namespaceURI);
               }
           }
  @@ -178,7 +188,7 @@
   
       private String searchTable(Hashtable t, String prefix)
       {
  -        if ((t != null) && (t.contains(prefix))) {
  +        if ((t != null) && (t != EMPTY) && (t.contains(prefix))) {
               Enumeration e = t.keys();
               while (e.hasMoreElements()) {
                   String uri = (String)e.nextElement();
  @@ -198,7 +208,7 @@
           if (!stack.isEmpty()) {
               for (int n = stack.size() - 1; n >= 0; n--) {
                   Hashtable t = (Hashtable)stack.elementAt(n);
  -                if ((t != null) && t.containsKey(namespaceURI))
  +                if ((t != null) && (t != EMPTY) && t.containsKey(namespaceURI))
                       return true;
               }
           }
  
  
  

Mime
View raw message