Matthias Brantner has proposed merging 
lp:~zorba-coders/zorba/collection-insert-without-copy into lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/collection-insert-without-copy/+merge/105148

no node copying during insertion into collection if the nodes are freshly 
constructed nodes
-- 
https://code.launchpad.net/~zorba-coders/zorba/collection-insert-without-copy/+merge/105148
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-05-07 23:43:04 +0000
+++ ChangeLog	2012-05-08 23:34:21 +0000
@@ -25,6 +25,10 @@
   * Added XQJ support.
   * Added CollectionManager and DocumentManager support for XQJ.
 
+Optimizations:
+  * optimized insertion into a collection (don't copy it if the node was created by an element constructor
+    and is not used anywhere else in the query
+
 Bug Fixes/Other Changes:
   * Fixed bugs #931501 and #866987 (improved error messages for fn:format-number(). Additionally, the function now throws the FODF1310 error instead of XTDE1310, as the 3.0 spec requires)
   * Fixed bug 955170 (Catch clause with URILiteral-based wilcard NameTest)

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-05-05 02:39:12 +0000
+++ src/compiler/translator/translator.cpp	2012-05-08 23:34:21 +0000
@@ -2195,7 +2195,7 @@
 {
   TRACE_VISIT();
 
-  if (v.get_encoding().length() != 0 &&
+  if (v.get_encoding() != "utf-8" &&
       !utf8::match_whole(v.get_encoding(), "^[A-Za-z]([A-Za-z0-9._]|[-])*$"))
     RAISE_ERROR(err::XQST0087, loc, ERROR_PARAMS(v.get_encoding()));
 

=== modified file 'src/runtime/base/plan_iterator.h'
--- src/runtime/base/plan_iterator.h	2012-05-03 12:31:51 +0000
+++ src/runtime/base/plan_iterator.h	2012-05-08 23:34:21 +0000
@@ -346,6 +346,8 @@
 
   TypeManager* getTypeManager() const;
 
+  virtual bool isConstructor() const { return false; }
+
   /**
    * Accept method for the PlanIterator-Tree-Visitor
    *

=== modified file 'src/runtime/collections/collections_base.h'
--- src/runtime/collections/collections_base.h	2012-05-03 12:31:51 +0000
+++ src/runtime/collections/collections_base.h	2012-05-08 23:34:21 +0000
@@ -128,6 +128,9 @@
 
     getCopyMode(lCopyMode, this->theSctx);
 
+    lCopyMode.theDoCopy = ! 
+    this->theChildren[this->theChildren.size()-1]->isConstructor();
+
     while (this->consumeNext(node, this->theChildren[this->theChildren.size()-1].getp(), planState))
     {
       checkNodeType(this->theSctx, node, collectionDecl, this->loc, theDynamicCollection);

=== modified file 'src/runtime/core/constructors.h'
--- src/runtime/core/constructors.h	2012-05-03 12:31:51 +0000
+++ src/runtime/core/constructors.h	2012-05-08 23:34:21 +0000
@@ -67,6 +67,8 @@
 
   bool copyInputNodes() const { return theCopyInputNodes; }
 
+  bool isConstructor() const { return true; }
+
   void accept(PlanIterVisitor& v) const;
 
   void openImpl(PlanState& planState, uint32_t& offset);
@@ -141,6 +143,8 @@
 
   bool copyInputNodes() const { return theCopyInputNodes; }
 
+  bool isConstructor() const { return true; }
+
   uint32_t getStateSizeOfSubtree() const;
   
   void accept(PlanIterVisitor&) const;
@@ -193,6 +197,8 @@
 
   store::Item* getQName() const { return theQName.getp(); }
 
+  bool isConstructor() const { return true; }
+
   void accept(PlanIterVisitor& v) const;
 
   bool nextImpl(store::Item_t& result, PlanState& planState) const;
@@ -234,6 +240,8 @@
         PlanIter_t& aChild,
         bool isRoot);
 
+  bool isConstructor() const { return true; }
+
   void accept(PlanIterVisitor& v) const;
 
   bool nextImpl(store::Item_t& result, PlanState& planState) const;
@@ -275,6 +283,8 @@
         PlanIter_t& aComment,
         bool isRoot);
 
+  bool isConstructor() const { return true; }
+
   void accept(PlanIterVisitor& v) const;
 
   bool nextImpl(store::Item_t& result, PlanState& planState) const;
@@ -314,6 +324,8 @@
         PlanIter_t& aContent,
         bool isRoot);
 
+  bool isConstructor() const { return true; }
+
   void accept(PlanIterVisitor& v) const;
 
   bool nextImpl(store::Item_t& result, PlanState& planState) const;

=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp	2012-05-03 12:31:51 +0000
+++ src/store/naive/node_items.cpp	2012-05-08 23:34:21 +0000
@@ -615,7 +615,14 @@
     }
   } // have parent
 
-  return copyInternal(parent, parent, pos, NULL, copymode);
+  if (copymode.theDoCopy)
+  {
+    return copyInternal(parent, parent, pos, NULL, copymode);
+  }
+  else
+  {
+    return const_cast<XmlNode*>(this);
+  }
 }
 
 

-- 
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