[PPL-devel] [GIT] ppl/ppl(master): Prefer explicit tests against zero.
Enea Zaffanella
zaffanella at cs.unipr.it
Sun Feb 26 13:00:52 CET 2012
Module: ppl/ppl
Branch: master
Commit: 0d2064c3d8080286fe7a3fb44065be95e271ff56
URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=0d2064c3d8080286fe7a3fb44065be95e271ff56
Author: Enea Zaffanella <zaffanella at cs.unipr.it>
Date: Sun Feb 26 12:59:39 2012 +0100
Prefer explicit tests against zero.
Avoid using boolean values as integer values.
Detected by ECLAIR service utypflag.
---
src/Congruence_System.cc | 6 ++++--
src/Interval_Info.defs.hh | 16 +++++++++-------
src/Ph_Status.inlines.hh | 2 +-
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/src/Congruence_System.cc b/src/Congruence_System.cc
index fc16b4f..87b2371 100644
--- a/src/Congruence_System.cc
+++ b/src/Congruence_System.cc
@@ -332,8 +332,10 @@ PPL::Congruence_System::has_a_free_dimension() const {
// Check that there are free_dims dimensions marked free
// in free_dim.
dimension_type count = 0;
- for (dimension_type i = space_dim; i-- > 0; )
- count += free_dim[i];
+ for (dimension_type i = space_dim; i-- > 0; ) {
+ if (free_dim[i])
+ ++count;
+ }
PPL_ASSERT(count == free_dims);
#endif
return true;
diff --git a/src/Interval_Info.defs.hh b/src/Interval_Info.defs.hh
index 5a2158e..95d91d9 100644
--- a/src/Interval_Info.defs.hh
+++ b/src/Interval_Info.defs.hh
@@ -170,13 +170,15 @@ public:
const_bool_nodef(cache_empty, Policy::cache_empty);
const_bool_nodef(cache_singleton, Policy::cache_singleton);
const_int_nodef(lower_special_bit, Policy::next_bit);
- const_int_nodef(lower_open_bit, lower_special_bit + store_special);
- const_int_nodef(upper_special_bit, lower_open_bit + store_open);
- const_int_nodef(upper_open_bit, upper_special_bit + store_special);
- const_int_nodef(cardinality_is_bit, upper_open_bit + store_open);
- const_int_nodef(cardinality_0_bit, cardinality_is_bit + ((cache_empty || cache_singleton) ? 1 : 0));
- const_int_nodef(cardinality_1_bit, cardinality_0_bit + cache_empty);
- const_int_nodef(next_bit, cardinality_1_bit + cache_singleton);
+ const_int_nodef(lower_open_bit, lower_special_bit + (store_special ? 1 : 0));
+ const_int_nodef(upper_special_bit, lower_open_bit + (store_open ? 1 : 0));
+ const_int_nodef(upper_open_bit, upper_special_bit + (store_special ? 1 : 0));
+ const_int_nodef(cardinality_is_bit, upper_open_bit + (store_open ? 1 : 0));
+ const_int_nodef(cardinality_0_bit, cardinality_is_bit
+ + ((cache_empty || cache_singleton) ? 1 : 0));
+ const_int_nodef(cardinality_1_bit, cardinality_0_bit + (cache_empty ? 1 : 0));
+ const_int_nodef(next_bit, cardinality_1_bit + (cache_singleton ? 1 : 0));
+
Interval_Info_Bitset() {
// FIXME: would we have speed benefits with uninitialized info?
// (Dirty_Temp)
diff --git a/src/Ph_Status.inlines.hh b/src/Ph_Status.inlines.hh
index 160507e..0c828de 100644
--- a/src/Ph_Status.inlines.hh
+++ b/src/Ph_Status.inlines.hh
@@ -43,7 +43,7 @@ Polyhedron::Status::test_all(flags_t mask) const {
inline bool
Polyhedron::Status::test_any(flags_t mask) const {
- return flags & mask;
+ return (flags & mask) != 0;
}
inline void
More information about the PPL-devel
mailing list