You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2012/10/02 20:23:11 UTC

svn commit: r1393083 - /incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java

Author: prestonc
Date: Tue Oct  2 18:23:11 2012
New Revision: 1393083

URL: http://svn.apache.org/viewvc?rev=1393083&view=rev
Log:
Removed an extra variable and some duplicate code.

Modified:
    incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java

Modified: incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java
URL: http://svn.apache.org/viewvc/incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java?rev=1393083&r1=1393082&r2=1393083&view=diff
==============================================================================
--- incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java (original)
+++ incubator/vxquery/trunk/vxquery/vxquery-core/src/main/java/org/apache/vxquery/serializer/XMLSerializer.java Tue Oct  2 18:23:11 2012
@@ -63,7 +63,6 @@ public class XMLSerializer implements IP
     private ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
     private DataOutput dOut = abvs.getDataOutput();
     private CastToStringOperation castToString = new CastToStringOperation();
-    private UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
 
     private boolean lastWasAtomic = false;
 
@@ -416,6 +415,7 @@ public class XMLSerializer implements IP
             dnp.getContent(ntp, seqp);
             printSequence(ps, seqp);
         } finally {
+            pp.giveBack(seqp);
             pp.giveBack(dnp);
         }
     }
@@ -717,8 +717,13 @@ public class XMLSerializer implements IP
     }
 
     private void printStringAbvs(PrintStream ps) {
-        stringp.set(abvs.getByteArray(), abvs.getStartOffset() + 1, abvs.getLength() - 1);
-        printString(ps, stringp);
+        UTF8StringPointable utf8sp = pp.takeOne(UTF8StringPointable.class);
+        try {
+            utf8sp.set(abvs.getByteArray(), abvs.getStartOffset() + 1, abvs.getLength() - 1);
+            printString(ps, utf8sp);
+        } finally {
+            pp.giveBack(utf8sp);
+        }
     }
 
     private void printString(PrintStream ps, TaggedValuePointable tvp) {
@@ -789,8 +794,7 @@ public class XMLSerializer implements IP
             tvp.getValue(ip);
             abvs.reset();
             castToString.convertYMDuration(ip, dOut);
-            stringp.set(abvs.getByteArray(), abvs.getStartOffset() + 1, abvs.getLength() - 1);
-            printString(ps, stringp);
+            printStringAbvs(ps);
         } catch (SystemException e) {
             e.printStackTrace();
         } catch (IOException e) {