Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57980 - trunk/boost/gil
From: chhenning_at_[hidden]
Date: 2009-11-27 15:18:21


Author: chhenning
Date: 2009-11-27 15:18:20 EST (Fri, 27 Nov 2009)
New Revision: 57980
URL: http://svn.boost.org/trac/boost/changeset/57980

Log:
Adding const ref to channel_convert function to reduce potential performance penalties.
Text files modified:
   trunk/boost/gil/channel_algorithm.hpp | 4 ++--
   trunk/boost/gil/gil_concept.hpp | 2 +-
   2 files changed, 3 insertions(+), 3 deletions(-)

Modified: trunk/boost/gil/channel_algorithm.hpp
==============================================================================
--- trunk/boost/gil/channel_algorithm.hpp (original)
+++ trunk/boost/gil/channel_algorithm.hpp 2009-11-27 15:18:20 EST (Fri, 27 Nov 2009)
@@ -348,7 +348,7 @@
 /// \brief A unary function object converting between channel types
 template <typename SrcChannelV, typename DstChannelV> // Model ChannelValueConcept
 struct channel_converter : public std::unary_function<SrcChannelV,DstChannelV> {
- DstChannelV operator()(SrcChannelV src) const {
+ DstChannelV operator()(const SrcChannelV& src) const {
         typedef detail::channel_convert_to_unsigned<SrcChannelV> to_unsigned;
         typedef detail::channel_convert_from_unsigned<DstChannelV> from_unsigned;
         typedef channel_converter_unsigned<typename to_unsigned::result_type, typename from_unsigned::argument_type> converter_unsigned;
@@ -359,7 +359,7 @@
 /// \ingroup ChannelConvertAlgorithm
 /// \brief Converting from one channel type to another.
 template <typename DstChannel, typename SrcChannel> // Model ChannelConcept (could be channel references)
-inline typename channel_traits<DstChannel>::value_type channel_convert(SrcChannel src) {
+inline typename channel_traits<DstChannel>::value_type channel_convert(const SrcChannel& src) {
     return channel_converter<typename channel_traits<SrcChannel>::value_type,
                              typename channel_traits<DstChannel>::value_type>()(src);
 }

Modified: trunk/boost/gil/gil_concept.hpp
==============================================================================
--- trunk/boost/gil/gil_concept.hpp (original)
+++ trunk/boost/gil/gil_concept.hpp 2009-11-27 15:18:20 EST (Fri, 27 Nov 2009)
@@ -35,7 +35,7 @@
 template <typename T> struct channel_traits;
 template <typename P> struct is_pixel;
 template <typename dstT, typename srcT>
-typename channel_traits<dstT>::value_type channel_convert(srcT val);
+typename channel_traits<dstT>::value_type channel_convert(const srcT& val);
 template <typename T> class point2;
 template <std::size_t K, typename T> const T& axis_value(const point2<T>& p);
 template <std::size_t K, typename T> T& axis_value( point2<T>& p);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk