You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2010/07/12 13:51:28 UTC

svn commit: r963245 - in /xerces/java/trunk/src/org/apache/xerces/impl/xs/opti: SchemaDOM.java SchemaDOMParser.java

Author: mrglavas
Date: Mon Jul 12 11:51:27 2010
New Revision: 963245

URL: http://svn.apache.org/viewvc?rev=963245&view=rev
Log:
Eliminate unnecessary creation of XMLStrings an char arrays in the construction of synthetic annotations.

Modified:
    xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java
    xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java?rev=963245&r1=963244&r2=963245&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOM.java Mon Jul 12 11:51:27 2010
@@ -52,7 +52,7 @@ public class SchemaDOM extends DefaultDo
     boolean inCDATA;
     
     // for annotation support:
-    StringBuffer fAnnotationBuffer = null;
+    private StringBuffer fAnnotationBuffer = null;
     
     public SchemaDOM() {
         reset();
@@ -165,32 +165,33 @@ public class SchemaDOM extends DefaultDo
     }
     
     // note that this will only be called within appinfo/documentation
-    void characters(XMLString text ) {
+    void characters(XMLString text) {
         
         // escape characters if necessary
-        if (!inCDATA) {   
-            for (int i = text.offset; i < text.offset+text.length; ++i ) {
+        if (!inCDATA) {
+            final StringBuffer annotationBuffer = fAnnotationBuffer;
+            for (int i = text.offset; i < text.offset+text.length; ++i) {
                 char ch = text.ch[i];
                 if (ch == '&') {
-                    fAnnotationBuffer.append("&amp;");
+                    annotationBuffer.append("&amp;");
                 } 
                 else if (ch == '<') {
-                    fAnnotationBuffer.append("&lt;");
+                    annotationBuffer.append("&lt;");
                 }
                 // character sequence "]]>" cannot appear in content, 
                 // therefore we should escape '>'.
                 else if (ch == '>') {
-                    fAnnotationBuffer.append("&gt;");
+                    annotationBuffer.append("&gt;");
                 }
                 // If CR is part of the document's content, it
                 // must not be printed as a literal otherwise
                 // it would be normalized to LF when the document
                 // is reparsed.
                 else if (ch == '\r') {
-                    fAnnotationBuffer.append("&#xD;");
+                    annotationBuffer.append("&#xD;");
                 }
                 else {
-                    fAnnotationBuffer.append(ch);
+                    annotationBuffer.append(ch);
                 }
             }
         }
@@ -199,6 +200,11 @@ public class SchemaDOM extends DefaultDo
         }
     }
     
+    // note that this will only be called within appinfo/documentation
+    void charactersRaw(String text) {
+        fAnnotationBuffer.append(text);
+    }
+    
     void endAnnotation(QName elemName, ElementImpl annotation) {
         fAnnotationBuffer.append("\n</").append(elemName.rawname).append(">");
         annotation.fAnnotation = fAnnotationBuffer.toString();

Modified: xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java?rev=963245&r1=963244&r2=963245&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/impl/xs/opti/SchemaDOMParser.java Mon Jul 12 11:51:27 2010
@@ -298,7 +298,7 @@ public class SchemaDOMParser extends Def
             schemaDOM.startAnnotation(annQName, attributes, fNamespaceContext);
             QName elemQName = new QName(schemaPrefix, SchemaSymbols.ELT_DOCUMENTATION, schemaPrefix + (schemaPrefix.length() == 0?"":":") + SchemaSymbols.ELT_DOCUMENTATION, SchemaSymbols.URI_SCHEMAFORSCHEMA);
             schemaDOM.startAnnotationElement(elemQName, attributes);
-            schemaDOM.characters(new XMLString("SYNTHETIC_ANNOTATION".toCharArray(), 0, 20 ));     
+            schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");     
             schemaDOM.endSyntheticAnnotationElement(elemQName, false);
             schemaDOM.endSyntheticAnnotationElement(annQName, true);
             
@@ -381,7 +381,7 @@ public class SchemaDOMParser extends Def
                     schemaDOM.startAnnotation(annQName, fEmptyAttr, fNamespaceContext);
                     QName elemQName = new QName(schemaPrefix, SchemaSymbols.ELT_DOCUMENTATION, schemaPrefix + (schemaPrefix.length() == 0?"":":") + SchemaSymbols.ELT_DOCUMENTATION, SchemaSymbols.URI_SCHEMAFORSCHEMA);
                     schemaDOM.startAnnotationElement(elemQName, fEmptyAttr);
-                    schemaDOM.characters(new XMLString("SYNTHETIC_ANNOTATION".toCharArray(), 0, 20 ));     
+                    schemaDOM.charactersRaw("SYNTHETIC_ANNOTATION");     
                     schemaDOM.endSyntheticAnnotationElement(elemQName, false);
                     schemaDOM.endSyntheticAnnotationElement(annQName, true);
                 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org