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

Commit message:
performance improvements for json array construction

Requested reviews:
  Matthias Brantner (matthias-brantner)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/msb-misc/+merge/152762
-- 
https://code.launchpad.net/~zorba-coders/zorba/msb-misc/+merge/152762
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'src/store/naive/json_items.h'
--- src/store/naive/json_items.h	2013-02-26 04:12:43 +0000
+++ src/store/naive/json_items.h	2013-03-11 19:47:36 +0000
@@ -407,6 +407,11 @@
   SimpleJSONArray()
   {}
 
+  SimpleJSONArray(size_t aReservedSize)
+  {
+    theContent.reserve(aReservedSize);
+  }
+
   virtual ~SimpleJSONArray();
 
   // store API

=== modified file 'src/store/naive/simple_item_factory.cpp'
--- src/store/naive/simple_item_factory.cpp	2013-03-07 10:10:10 +0000
+++ src/store/naive/simple_item_factory.cpp	2013-03-11 19:47:36 +0000
@@ -2172,13 +2172,13 @@
     const std::vector<store::Iterator_t>& sources,
     const std::vector<store::CopyMode>& copyModes)
 {
-  result = new json::SimpleJSONArray();
+  csize numSources = sources.size();
+
+  result = new json::SimpleJSONArray(numSources);
 
   json::JSONArray* array = static_cast<json::JSONArray*>(result.getp());
 
   store::Item_t item;
-
-  csize numSources = sources.size();
   for (csize i = 0; i < numSources; ++i)
   {
     store::Iterator* source = sources[i].getp();
@@ -2233,12 +2233,8 @@
 
   json::JSONArray* array = static_cast<json::JSONArray*>(result.getp());
 
-  std::vector<store::Item_t>::const_iterator ite = items.begin();
-  std::vector<store::Item_t>::const_iterator end = items.end();
-  for (; ite != end; ++ite)
-  {
-    array->push_back(*ite);
-  }
+  array->push_back(items);
+
   return true;
 }
 

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