From fa0a51444e1d243b0272c8cd409b2fc449f10b87 Mon Sep 17 00:00:00 2001 From: Sylvain Pion Date: Wed, 2 Apr 2008 09:00:45 +0000 Subject: [PATCH] Pass Uncertain and T (enum or bool) by value instead of by reference. It is generally accepted that it is more efficient for small classes like this (and it's definitely shorter and more readable). --- Filtered_kernel/include/CGAL/Uncertain.h | 60 ++++++++++++------------ 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Uncertain.h b/Filtered_kernel/include/CGAL/Uncertain.h index ab5352f0c06..e4b23a9c2c9 100644 --- a/Filtered_kernel/include/CGAL/Uncertain.h +++ b/Filtered_kernel/include/CGAL/Uncertain.h @@ -97,19 +97,19 @@ public: : _i(CGALi::Minmax_traits::min), _s(CGALi::Minmax_traits::max) {} - Uncertain(const T & t) + Uncertain(T t) : _i(t), _s(t) {} - Uncertain(const T & i, const T & s) + Uncertain(T i, T s) : _i(i), _s(s) {} - const T & inf() const { return _i; } - const T & sup() const { return _s; } + T inf() const { return _i; } + T sup() const { return _s; } // NB : conversion to bool might be too risky // (boost::tribool uses something else). - operator const T &() const + operator T() const { if (_i == _s) return _i; @@ -135,14 +135,14 @@ Uncertain::failures = 0; template < typename T > inline -const T & inf(Uncertain const& i) +T inf(Uncertain i) { return i.inf(); } template < typename T > inline -const T & sup(Uncertain const& i) +T sup(Uncertain i) { return i.sup(); } @@ -161,21 +161,21 @@ Uncertain::indeterminate() template < typename T > inline -bool is_indeterminate(T const&) +bool is_indeterminate(T) { return false; } template < typename T > inline -bool is_indeterminate(Uncertain const& a) +bool is_indeterminate(Uncertain a) { return a.inf() != a.sup(); } template < typename T > inline -bool is_singleton(Uncertain const& a) +bool is_singleton(Uncertain a) { return a.inf() == a.sup(); } @@ -185,43 +185,43 @@ bool is_singleton(Uncertain const& a) // -------------------------------------- inline -Uncertain operator!(Uncertain const& a) +Uncertain operator!(Uncertain a) { return Uncertain(!a.sup(), !a.inf()); } inline -Uncertain operator|(Uncertain const& a, Uncertain const& b) +Uncertain operator|(Uncertain a, Uncertain b) { return Uncertain(a.inf() || b.inf(), a.sup() || b.sup()); } inline -Uncertain operator|(bool a, Uncertain const& b) +Uncertain operator|(bool a, Uncertain b) { return Uncertain(a || b.inf(), a || b.sup()); } inline -Uncertain operator|(Uncertain const& a, bool b) +Uncertain operator|(Uncertain a, bool b) { return Uncertain(a.inf() || b, a.sup() || b); } inline -Uncertain operator&(Uncertain const& a, Uncertain const& b) +Uncertain operator&(Uncertain a, Uncertain b) { return Uncertain(a.inf() && b.inf(), a.sup() && b.sup()); } inline -Uncertain operator&(bool a, Uncertain const& b) +Uncertain operator&(bool a, Uncertain b) { return Uncertain(a && b.inf(), a && b.sup()); } inline -Uncertain operator&(Uncertain const& a, bool b) +Uncertain operator&(Uncertain a, bool b) { return Uncertain(a.inf() && b, a.sup() && b); } @@ -231,7 +231,7 @@ Uncertain operator&(Uncertain const& a, bool b) template < typename T > inline -Uncertain operator==(Uncertain const& a, Uncertain const& b) +Uncertain operator==(Uncertain a, Uncertain b) { if (is_indeterminate(a) || is_indeterminate(b)) return Uncertain::indeterminate(); @@ -240,7 +240,7 @@ Uncertain operator==(Uncertain const& a, Uncertain const& b) template < typename T > inline -Uncertain operator==(Uncertain const& a, const T & b) +Uncertain operator==(Uncertain a, T b) { if (is_indeterminate(a)) return Uncertain::indeterminate(); @@ -249,7 +249,7 @@ Uncertain operator==(Uncertain const& a, const T & b) template < typename T > inline -Uncertain operator==(const T & a, Uncertain const& b) +Uncertain operator==(T a, Uncertain b) { if (is_indeterminate(b)) return Uncertain::indeterminate(); @@ -258,21 +258,21 @@ Uncertain operator==(const T & a, Uncertain const& b) template < typename T > inline -Uncertain operator!=(Uncertain const& a, Uncertain const& b) +Uncertain operator!=(Uncertain a, Uncertain b) { return ! (a == b); } template < typename T > inline -Uncertain operator!=(Uncertain const& a, const T & b) +Uncertain operator!=(Uncertain a, T b) { return ! (a == b); } template < typename T > inline -Uncertain operator!=(const T & a, Uncertain const& b) +Uncertain operator!=(T a, Uncertain b) { return ! (a == b); } @@ -381,14 +381,14 @@ Uncertain operator>=(T a, Uncertain b) template < typename T > inline -Uncertain make_uncertain(const T&t) +Uncertain make_uncertain(T t) { return Uncertain(t); } template < typename T > inline -const Uncertain & make_uncertain(const Uncertain &t) +Uncertain make_uncertain(Uncertain t) { return t; } @@ -397,7 +397,7 @@ const Uncertain & make_uncertain(const Uncertain &t) // opposite template < typename T > // should be constrained only for enums. inline -Uncertain operator-(const Uncertain &u) +Uncertain operator-(Uncertain u) { return Uncertain(-u.sup(), -u.inf()); } @@ -457,7 +457,7 @@ Uncertain operator*(Uncertain a, Uncertain b) template < typename T, typename U > inline -Uncertain enum_cast_bug(const Uncertain& u, const T*) +Uncertain enum_cast_bug(Uncertain u, const T*) { return Uncertain(static_cast(u.inf()), static_cast(u.sup())); @@ -467,7 +467,7 @@ Uncertain enum_cast_bug(const Uncertain& u, const T*) template < typename T, typename U > inline -Uncertain enum_cast(const Uncertain& u) +Uncertain enum_cast(Uncertain u) { return Uncertain(static_cast(u.inf()), static_cast(u.sup())); } @@ -481,7 +481,7 @@ inline bool certainly(bool b) { return b; } inline bool possibly(bool b) { return b; } inline -bool certainly(Uncertain const& c) +bool certainly(Uncertain c) { if (is_indeterminate(c)) return false; @@ -489,7 +489,7 @@ bool certainly(Uncertain const& c) } inline -bool possibly(Uncertain const& c) +bool possibly(Uncertain c) { if (is_indeterminate(c)) return true;