Matthias Brantner has proposed merging lp:~zorba-coders/zorba/fnserialize into 
lp:zorba.

Requested reviews:
  Till Westmann (tillw)
  Matthias Brantner (matthias-brantner)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/fnserialize/+merge/89504

fn:serialize avoids copying the result but returns a streamable string instead
-- 
https://code.launchpad.net/~zorba-coders/zorba/fnserialize/+merge/89504
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp'
--- src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp	2011-08-10 02:50:23 +0000
+++ src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp	2012-01-20 22:06:28 +0000
@@ -122,12 +122,16 @@
 /*******************************************************************************
   14.9.2 fn:serialize
 ********************************************************************************/
+void
+FnSerializeIterator::streamReleaser(std::istream* s)
+{
+  delete s;
+}
+
 bool
 FnSerializeIterator::nextImpl(store::Item_t& aResult, PlanState& aPlanState) const
 {
   store::Item_t lParams;
-  std::stringstream lResultStream;
-  zstring lResult;
 
   PlanIteratorState* lState;
   DEFAULT_STACK_INIT(PlanIteratorState, lState, aPlanState);
@@ -254,12 +258,15 @@
       lElemIter->close();
     }
 
-    // and now serialize
-    lSerializer.serialize(lIterWrapper, lResultStream);
-    lResult = lResultStream.str();
+    {
+      // and now serialize
+      std::auto_ptr<std::stringstream> lResultStream(new std::stringstream());
+      lSerializer.serialize(lIterWrapper, *lResultStream.get());
+      GENV_ITEMFACTORY->createStreamableString(aResult, *lResultStream.release(), FnSerializeIterator::streamReleaser, true);
+    }
   }
+  STACK_PUSH(true, lState);
 
-  STACK_PUSH(GENV_ITEMFACTORY->createString(aResult, lResult), lState);
   STACK_END (lState);
 }
 

=== modified file 'src/runtime/parsing_and_serializing/pregenerated/parsing_and_serializing.h'
--- src/runtime/parsing_and_serializing/pregenerated/parsing_and_serializing.h	2011-10-19 15:28:51 +0000
+++ src/runtime/parsing_and_serializing/pregenerated/parsing_and_serializing.h	2012-01-20 22:06:28 +0000
@@ -95,6 +95,8 @@
 
   virtual ~FnSerializeIterator();
 
+public:
+  static void streamReleaser(std::istream* stream);
   void accept(PlanIterVisitor& v) const;
 
   bool nextImpl(store::Item_t& result, PlanState& aPlanState) const;

=== modified file 'src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml'
--- src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml	2012-01-11 17:30:25 +0000
+++ src/runtime/spec/parsing_and_serializing/parsing_and_serializing.xml	2012-01-20 22:06:28 +0000
@@ -74,6 +74,10 @@
 
     </zorba:function>
 
+    <zorba:method static="true" name="streamReleaser" return="void">
+      <zorba:param type="std::istream*" name="stream"/>
+    </zorba:method>
+
   </zorba:iterator>
   
 </zorba:iterators>

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to