Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53590 - in trunk/boost/xpressive: . detail/core detail/utility
From: eric_at_[hidden]
Date: 2009-06-02 21:45:49


Author: eric_niebler
Date: 2009-06-02 21:45:48 EDT (Tue, 02 Jun 2009)
New Revision: 53590
URL: http://svn.boost.org/trac/boost/changeset/53590

Log:
don't copy singular iterators, fixes #3124
Text files modified:
   trunk/boost/xpressive/detail/core/state.hpp | 4 ++--
   trunk/boost/xpressive/detail/core/sub_match_impl.hpp | 15 +++++++++++++++
   trunk/boost/xpressive/detail/utility/sequence_stack.hpp | 18 ++++++------------
   trunk/boost/xpressive/match_results.hpp | 2 +-
   4 files changed, 24 insertions(+), 15 deletions(-)

Modified: trunk/boost/xpressive/detail/core/state.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/state.hpp (original)
+++ trunk/boost/xpressive/detail/core/state.hpp 2009-06-02 21:45:48 EDT (Tue, 02 Jun 2009)
@@ -289,7 +289,7 @@
         this->context_.results_ptr_ = &what;
         this->context_.traits_ = impl.traits_.get();
         this->mark_count_ = impl.mark_count_ + 1;
- this->sub_matches_ = this->extras_->sub_match_stack_.push_sequence(total_mark_count);
+ this->sub_matches_ = this->extras_->sub_match_stack_.push_sequence(total_mark_count, detail::sub_match_impl_default());
         this->sub_matches_ += impl.hidden_mark_count_;
 
         // initialize the match_results struct
@@ -329,7 +329,7 @@
 {
     memento<BidiIter> mem =
     {
- state.extras_->sub_match_stack_.push_sequence(state.mark_count_, no_fill)
+ state.extras_->sub_match_stack_.push_sequence(state.mark_count_)
       , state.context_.results_ptr_->nested_results().size()
       , state.action_list_.next
       , state.action_list_tail_

Modified: trunk/boost/xpressive/detail/core/sub_match_impl.hpp
==============================================================================
--- trunk/boost/xpressive/detail/core/sub_match_impl.hpp (original)
+++ trunk/boost/xpressive/detail/core/sub_match_impl.hpp 2009-06-02 21:45:48 EDT (Tue, 02 Jun 2009)
@@ -23,6 +23,13 @@
 // need is trivial constructor/destructor. (???)
 
 ///////////////////////////////////////////////////////////////////////////////
+// sub_match_impl_default
+//
+struct sub_match_impl_default
+{
+};
+
+///////////////////////////////////////////////////////////////////////////////
 // sub_match_impl
 //
 template<typename BidiIter>
@@ -40,6 +47,14 @@
       , zero_width_(false)
     {
     }
+
+ sub_match_impl &operator =(sub_match_impl_default const &)
+ {
+ this->matched = false;
+ this->repeat_count_ = 0;
+ this->zero_width_ = false;
+ return *this;
+ }
 };
 
 }}} // namespace boost::xpressive::detail

Modified: trunk/boost/xpressive/detail/utility/sequence_stack.hpp
==============================================================================
--- trunk/boost/xpressive/detail/utility/sequence_stack.hpp (original)
+++ trunk/boost/xpressive/detail/utility/sequence_stack.hpp 2009-06-02 21:45:48 EDT (Tue, 02 Jun 2009)
@@ -173,8 +173,7 @@
         this->begin_ = this->curr_ = this->end_ = 0;
     }
 
- template<bool Fill>
- T *push_sequence(std::size_t count, mpl::bool_<Fill>)
+ T *push_sequence(std::size_t count)
     {
         // This is the ptr to return
         T *ptr = this->curr_;
@@ -192,17 +191,15 @@
             return this->grow_(count);
         }
 
- if(Fill)
- {
- std::fill_n(ptr, count, T());
- }
-
         return ptr;
     }
 
- T *push_sequence(std::size_t count)
+ template<typename U>
+ T *push_sequence(std::size_t count, U const &u)
     {
- return this->push_sequence(count, mpl::true_());
+ T *ptr = this->push_sequence(count);
+ std::fill_n(ptr, count, u);
+ return ptr;
     }
 
     void unwind_to(T *ptr)
@@ -229,9 +226,6 @@
     }
 };
 
-typedef mpl::false_ no_fill_t;
-no_fill_t const no_fill = {};
-
 }}} // namespace boost::xpressive::detail
 
 #if defined(_MSC_VER) && (_MSC_VER >= 1020)

Modified: trunk/boost/xpressive/match_results.hpp
==============================================================================
--- trunk/boost/xpressive/match_results.hpp (original)
+++ trunk/boost/xpressive/match_results.hpp 2009-06-02 21:45:48 EDT (Tue, 02 Jun 2009)
@@ -410,7 +410,7 @@
         {
             extras_type &extras = this->get_extras_();
             std::size_t size = that.sub_matches_.size();
- detail::sub_match_impl<BidiIter> *sub_matches = extras.sub_match_stack_.push_sequence(size);
+ detail::sub_match_impl<BidiIter> *sub_matches = extras.sub_match_stack_.push_sequence(size, detail::sub_match_impl_default());
             detail::core_access<BidiIter>::init_sub_match_vector(this->sub_matches_, sub_matches, size, that.sub_matches_);
 
             // BUGBUG this doesn't share the extras::sequence_stack


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