cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r712194 - in /cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils: StaxUtils.java W3CDOMStreamReader.java
Date Fri, 07 Nov 2008 16:49:14 GMT
Author: dkulp
Date: Fri Nov  7 08:49:07 2008
New Revision: 712194

URL: http://svn.apache.org/viewvc?rev=712194&view=rev
Log:
Minor performance improvement be removing a bunch of instanceof things in chained if..else..else..else
things

Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=712194&r1=712193&r2=712194&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Fri Nov
 7 08:49:07 2008
@@ -582,22 +582,31 @@
 
     public static void writeNode(Node n, XMLStreamWriter writer, boolean repairing) 
         throws XMLStreamException {
-        if (n instanceof Element) {
+        
+        switch (n.getNodeType()) {
+        case Node.ELEMENT_NODE:
             writeElement((Element)n, writer, repairing);
-        } else if (n instanceof CDATASection) {
-            writer.writeCData(((CDATASection)n).getData());
-        } else if (n instanceof Text) {
+            break;
+        case Node.TEXT_NODE:
             writer.writeCharacters(((Text)n).getNodeValue());
-        } else if (n instanceof Comment) {
+            break;
+        case Node.COMMENT_NODE:
             writer.writeComment(((Comment)n).getData());
-        } else if (n instanceof EntityReference) {
+            break;
+        case Node.CDATA_SECTION_NODE:
+            writer.writeCData(((CDATASection)n).getData());
+            break;
+        case Node.ENTITY_REFERENCE_NODE:
             writer.writeEntityRef(((EntityReference)n).getNodeValue());
-        } else if (n instanceof ProcessingInstruction) {
+            break;
+        case Node.PROCESSING_INSTRUCTION_NODE:
             ProcessingInstruction pi = (ProcessingInstruction)n;
             writer.writeProcessingInstruction(pi.getTarget(), pi.getData());
-        } else if (n instanceof Document) {
+            break;
+        case Node.DOCUMENT_NODE:
             writeDocument((Document)n, writer, repairing);
-        } 
+            break;
+        }        
     }
 
     public static Document read(XMLStreamReader reader) throws XMLStreamException {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java?rev=712194&r1=712193&r2=712194&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/W3CDOMStreamReader.java
Fri Nov  7 08:49:07 2008
@@ -151,16 +151,16 @@
             content = content.getNextSibling();
             --currentChild;
         }
-        
-        if (content instanceof Element) {
+        switch (content.getNodeType()) {
+        case Node.ELEMENT_NODE:
             return START_ELEMENT;
-        } else if (content instanceof CDATASection) {
-            return CDATA;
-        } else if (content instanceof Comment) {
-            return COMMENT;
-        } else if (content instanceof Text) {
+        case Node.TEXT_NODE:
             return CHARACTERS;
-        } else if (content instanceof EntityReference) {
+        case Node.COMMENT_NODE:
+            return COMMENT;
+        case Node.CDATA_SECTION_NODE:
+            return CDATA;
+        case Node.ENTITY_REFERENCE_NODE:
             return ENTITY_REFERENCE;
         }
 



Mime
View raw message