[PPL-devel] [GIT] ppl/ppl(sparse_matrices): CO_Tree: don' t use an iterator in move_data_from().

Marco Poletti poletti.marco at gmail.com
Sun Aug 8 08:54:25 CEST 2010


Module: ppl/ppl
Branch: sparse_matrices
Commit: 55e47337b37778041bfaabfdec99d572f58499cb
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=55e47337b37778041bfaabfdec99d572f58499cb

Author: Marco Poletti <poletti.marco at gmail.com>
Date:   Sun Aug  8 08:55:58 2010 +0200

CO_Tree: don't use an iterator in move_data_from().

---

 src/CO_Tree.cc |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/CO_Tree.cc b/src/CO_Tree.cc
index 57fb757..b7fad8f 100644
--- a/src/CO_Tree.cc
+++ b/src/CO_Tree.cc
@@ -201,10 +201,10 @@ PPL::CO_Tree::move_data_from(CO_Tree& tree) {
     return;
 
   tree_iterator root(*this);
-  iterator itr = tree.before_begin();
-  itr.get_next_value();
 
-  PPL_ASSERT(itr->first != unused_index);
+  dimension_type source_index = 1;
+  while (tree.indexes[source_index] == unused_index)
+    ++source_index;
 
   // This is static and with static allocation, to improve performance.
   static std::pair<dimension_type,char> stack[5*CHAR_BIT*sizeof(dimension_type)];
@@ -261,11 +261,14 @@ PPL::CO_Tree::move_data_from(CO_Tree& tree) {
     } else {
       if (top_n == 1) {
         PPL_ASSERT(root->first == unused_index);
-        PPL_ASSERT(itr->first != unused_index);
-        root->first = itr->first;
-        itr->first = unused_index;
-        move_data_element(root->second, itr->second);
-        itr.get_next_value();
+        PPL_ASSERT(tree.indexes[source_index] != unused_index);
+        root->first = tree.indexes[source_index];
+        tree.indexes[source_index] = unused_index;
+        move_data_element(root->second, tree.data[source_index]);
+        PPL_ASSERT(source_index <= tree.reserved_size);
+        ++source_index;
+        while (tree.indexes[source_index] == unused_index)
+          ++source_index;
         --stack_first_empty;
       } else {
         PPL_ASSERT(stack_first_empty + 3 < sizeof(stack)/sizeof(stack[0]));




More information about the PPL-devel mailing list