[PPL-devel] [GIT] ppl/ppl(sparse_matrices): CO_Tree: simplify code in the init() method .

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


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

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

CO_Tree: simplify code in the init() method.

---

 src/CO_Tree.cc |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/src/CO_Tree.cc b/src/CO_Tree.cc
index c7f9229..57fb757 100644
--- a/src/CO_Tree.cc
+++ b/src/CO_Tree.cc
@@ -162,16 +162,10 @@ PPL::CO_Tree::init(dimension_type reserved_size1) {
     return;
   }
 
-  height_t l = 0;
+  max_depth = integer_log2(reserved_size1) + 1;
 
-  if (reserved_size1 == 0)
-    reserved_size1 = 1;
-
-  l = integer_log2(reserved_size1);
-  // Add 1 to the log.
-  l++;
-
-  reserved_size = ((dimension_type)1 << l) - 1;
+  size = 0;
+  reserved_size = ((dimension_type)1 << max_depth) - 1;
   indexes = new dimension_type[reserved_size + 2];
   data = static_cast<data_type*>(operator new(sizeof(data_type)
                                               * (reserved_size + 1)));
@@ -183,10 +177,6 @@ PPL::CO_Tree::init(dimension_type reserved_size1) {
   indexes[0] = 0;
   indexes[reserved_size + 1] = 0;
 
-  max_depth = l;
-
-  size = 0;
-
   PPL_ASSERT(structure_OK());
 }
 




More information about the PPL-devel mailing list