[PPL-devel] [GIT] ppl/ppl(master): PIP_Tree: simplify unnecessarily complicated code in compatibility_check_find_pivot_in_set ().
Marco Poletti
poletti.marco at gmail.com
Mon Feb 14 21:24:05 CET 2011
Module: ppl/ppl
Branch: master
Commit: 73cfc6e2390366f132e6967d225c4d5ec317bb46
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=73cfc6e2390366f132e6967d225c4d5ec317bb46
Author: Marco Poletti <poletti.marco at gmail.com>
Date: Mon Feb 14 21:23:11 2011 +0100
PIP_Tree: simplify unnecessarily complicated code in compatibility_check_find_pivot_in_set().
---
src/PIP_Tree.cc | 31 +++++++++++--------------------
1 files changed, 11 insertions(+), 20 deletions(-)
diff --git a/src/PIP_Tree.cc b/src/PIP_Tree.cc
index 2660877..c9fe387 100644
--- a/src/PIP_Tree.cc
+++ b/src/PIP_Tree.cc
@@ -622,6 +622,7 @@ compatibility_check_find_pivot_in_set(
// Not in base.
const Row& row = s[row_index];
Row::const_iterator row_itr = row.lower_bound(pj);
+ Row::const_iterator new_row_itr;
Row::const_iterator row_end = row.end();
PPL_DIRTY_TEMP_COEFFICIENT(row_value);
if (row_itr != row_end && row_itr.index() == pj) {
@@ -629,6 +630,7 @@ compatibility_check_find_pivot_in_set(
++row_itr;
} else
row_value = 0;
+ PPL_DIRTY_TEMP_COEFFICIENT(row_challenger_value);
for (++i; i != i_end; ++i) {
const dimension_type challenger_j = i->first;
Coefficient_traits::const_reference challenger_cost = i->second.cost;
@@ -638,27 +640,16 @@ compatibility_check_find_pivot_in_set(
PPL_ASSERT(challenger_value > 0);
PPL_ASSERT(pj < challenger_j);
- PPL_DIRTY_TEMP_COEFFICIENT(row_challenger_value);
- // row_challenger_value = &(row.get(challenger_j));
- if (row_itr != row_end) {
- if (row_itr.index() < challenger_j) {
- row_itr = row.lower_bound(row_itr, challenger_j);
- if (row_itr != row_end && row_itr.index() == challenger_j) {
- row_challenger_value = *row_itr;
- ++row_itr;
- } else
- row_challenger_value = 0;
- } else {
- if (row_itr.index() == challenger_j) {
- row_challenger_value = *row_itr;
- ++row_itr;
- } else {
- PPL_ASSERT(row_itr.index() > challenger_j);
- row_challenger_value = 0;
- }
- }
- } else
+ new_row_itr = row.find(row_itr, challenger_j);
+ if (new_row_itr != row.end()) {
+ row_challenger_value = *new_row_itr;
+ // Use new_row_itr as a hint in next iterations
+ row_itr = new_row_itr;
+ } else {
row_challenger_value = 0;
+ // Using end() as a hint is not useful, keep the current hint.
+ }
+ PPL_ASSERT(row_challenger_value == row.get(challenger_j));
// Before computing and comparing the actual values, the signs are
// compared. This speeds up the code, because the values' computation
More information about the PPL-devel
mailing list