santiagopg    2002/09/21 10:55:05

  Modified:    java/src/org/apache/xalan/xsltc/dom DOMImpl.java
  Log:
  (1) Synchronize access to static variable.
  (2) Pre-allocate static objects for attribute and element types.
  
  Revision  Changes    Path
  1.83      +13 -9     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java
  
  Index: DOMImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMImpl.java,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- DOMImpl.java      14 Sep 2002 23:36:17 -0000      1.82
  +++ DOMImpl.java      21 Sep 2002 17:55:05 -0000      1.83
  @@ -153,6 +153,10 @@
       private final static String XML_LANG_ATTRIBUTE =
        "http://www.w3.org/XML/1998/namespace:@lang";;
   
  +    // Types for generic elements and attributes
  +    private final static Integer elementInt = new Integer(ELEMENT);
  +    private final static Integer attributeInt = new Integer(ATTRIBUTE);
  +
       /**
        * Define the origin of the document from which the tree was built
        */
  @@ -164,7 +168,10 @@
        * Returns the origin of the document from which the tree was built
        */
       public String getDocumentURI() {
  -     return (_documentURI != null) ? _documentURI : "rtf" + 
_documentURIIndex++;
  +     synchronized (getClass()) {     // synchornize access to static
  +         return (_documentURI != null) ? _documentURI : 
  +                                         "rtf" + _documentURIIndex++;
  +     }
       }
   
       public String getDocumentURI(int node) {
  @@ -2053,16 +2060,13 @@
        * Returns the internal type associated with an expaneded QName
        */
       public int getGeneralizedType(final String name) {
  -     final Integer type = (Integer)_types.get(name);
  +     Integer type = (Integer)_types.get(name);
        if (type == null) {
            // memorize default type
  -         final int code = name.charAt(0) == '@' ? ATTRIBUTE : ELEMENT;
  -         _types.put(name, new Integer(code));
  -         return code;
  -     }
  -     else {
  -         return type.intValue();
  +         _types.put(name, 
  +             type = (name.charAt(0) == '@') ? attributeInt : elementInt);
        }
  +     return type.intValue();
       }
   
       /**
  
  
  

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

Reply via email to