Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55032 - in trunk/boost/spirit/home/karma: detail numeric/detail
From: hartmut.kaiser_at_[hidden]
Date: 2009-07-19 15:50:58


Author: hkaiser
Date: 2009-07-19 15:50:58 EDT (Sun, 19 Jul 2009)
New Revision: 55032
URL: http://svn.boost.org/trac/boost/changeset/55032

Log:
Spirit: minor performance tweaks
Text files modified:
   trunk/boost/spirit/home/karma/detail/output_iterator.hpp | 19 ++++++++++++++-----
   trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp | 6 +++---
   2 files changed, 17 insertions(+), 8 deletions(-)

Modified: trunk/boost/spirit/home/karma/detail/output_iterator.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/detail/output_iterator.hpp (original)
+++ trunk/boost/spirit/home/karma/detail/output_iterator.hpp 2009-07-19 15:50:58 EDT (Sun, 19 Jul 2009)
@@ -64,25 +64,32 @@
     public:
         counting_sink(OutputIterator& sink_, std::size_t count_ = 0
               , bool enabled = true)
- : count(count_), prev_count(0), sink(sink_)
+ : count(count_), initial_count(count), prev_count(0), sink(sink_)
         {
             prev_count = sink.chain_counting(enabled ? this : NULL);
         }
         ~counting_sink()
         {
+ if (prev_count) // propagate count
+ prev_count->update_count(count-initial_count);
             sink.chain_counting(prev_count);
         }
 
         void output()
         {
             ++count;
- if (prev_count) // propagate count
- prev_count->output();
         }
         std::size_t get_count() const { return count; }
 
+ // propagate count from embedded counters
+ void update_count(std::size_t c)
+ {
+ count += c;
+ }
+
     private:
         std::size_t count;
+ std::size_t initial_count;
         counting_sink* prev_count; // previous counter in chain
         OutputIterator& sink;
     };
@@ -280,10 +287,12 @@
         typedef void reference;
 
         explicit output_iterator(OutputIterator& sink_)
- : sink(sink_), count(NULL), buffer(NULL)
+ : sink(sink_)
+ , count(NULL), buffer(NULL)
         {}
         output_iterator(output_iterator const& rhs)
- : sink(rhs.sink), count(rhs.count), buffer(rhs.buffer)
+ : sink(rhs.sink)
+ , count(rhs.count), buffer(rhs.buffer)
           , track_position_data(rhs.track_position_data)
         {}
 

Modified: trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp
==============================================================================
--- trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp (original)
+++ trunk/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp 2009-07-19 15:50:58 EDT (Sun, 19 Jul 2009)
@@ -308,7 +308,7 @@
             }
 
             template <typename T>
- static T call(T& n, T, int)
+ static T call(T& n, T const&, int)
             {
                 return call(n, mpl::bool_<is_integral<T>::value>());
             }
@@ -316,7 +316,7 @@
             template <typename T>
             static T call(T& n)
             {
- return call(n, n, 1);
+ return call(n, mpl::bool_<is_integral<T>::value>());
             }
         };
 
@@ -347,7 +347,7 @@
             template <typename T>
             static T call(T& n)
             {
- return call(n, n, 1);
+ return call(n, n, 1, mpl::bool_<is_integral<T>::value>());
             }
         };
 


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