From a5e7591328ef2e35e631748cbc0dc487d0702a9a Mon Sep 17 00:00:00 2001 From: Michael Hemmer Date: Thu, 2 Sep 2010 15:33:28 +0000 Subject: [PATCH] return const & where possible --- Polynomial/include/CGAL/Polynomial_traits_d.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Polynomial/include/CGAL/Polynomial_traits_d.h b/Polynomial/include/CGAL/Polynomial_traits_d.h index c31a357f07f..12136244898 100644 --- a/Polynomial/include/CGAL/Polynomial_traits_d.h +++ b/Polynomial/include/CGAL/Polynomial_traits_d.h @@ -351,7 +351,7 @@ public: struct Innermost_leading_coefficient :public std::unary_function { - ICoeff operator()(const ICoeff& x){return x;} + const ICoeff& operator()(const ICoeff& x){return x;} }; struct Degree_vector{ @@ -365,7 +365,7 @@ public: struct Get_innermost_coefficient : public std::binary_function< ICoeff, Polynomial_d, Exponent_vector > { - ICoeff operator()( const Polynomial_d& p, Exponent_vector ) { + const ICoeff& operator()( const Polynomial_d& p, Exponent_vector ) { return p; } }; @@ -699,11 +699,12 @@ public: struct Get_coefficient : public std::binary_function { - Coefficient_type operator()( const Polynomial_d& p, int i) const { + const Coefficient_type& operator()( const Polynomial_d& p, int i) const { + static const Coefficient_type zero = Coefficient_type(0); CGAL_precondition( i >= 0 ); typename PT::Degree degree; if( i > degree(p) ) - return Coefficient_type(0); + return zero; return p[i]; } }; @@ -714,7 +715,7 @@ public: std::binary_function< Polynomial_d, Exponent_vector, Innermost_coefficient_type > { - Innermost_coefficient_type + const Innermost_coefficient_type& operator()( const Polynomial_d& p, Exponent_vector ev ) const { CGAL_precondition( !ev.empty() ); typename PTC::Get_innermost_coefficient gic; @@ -848,7 +849,7 @@ public: // Leading_coefficient; struct Leading_coefficient : public std::unary_function< Polynomial_d , Coefficient_type>{ - Coefficient_type operator()(const Polynomial_d& p) const { + const Coefficient_type& operator()(const Polynomial_d& p) const { return p.lcoeff(); } }; @@ -856,7 +857,7 @@ public: // Innermost_leading_coefficient; struct Innermost_leading_coefficient : public std::unary_function< Polynomial_d , Innermost_coefficient_type>{ - Innermost_coefficient_type + const Innermost_coefficient_type& operator()(const Polynomial_d& p) const { typename PTC::Innermost_leading_coefficient ilcoeff; typename PT::Leading_coefficient lcoeff;