Boost logo

Boost-Commit :

From: john_at_[hidden]
Date: 2008-01-27 13:43:36


Author: johnmaddock
Date: 2008-01-27 13:43:35 EST (Sun, 27 Jan 2008)
New Revision: 42992
URL: http://svn.boost.org/trac/boost/changeset/42992

Log:
Extended leading repeat optimization to more cases.
Text files modified:
   trunk/boost/regex/v4/basic_regex_creator.hpp | 13 +++++++++++++
   trunk/boost/regex/v4/perl_matcher_non_recursive.hpp | 9 +++++++++
   2 files changed, 22 insertions(+), 0 deletions(-)

Modified: trunk/boost/regex/v4/basic_regex_creator.hpp
==============================================================================
--- trunk/boost/regex/v4/basic_regex_creator.hpp (original)
+++ trunk/boost/regex/v4/basic_regex_creator.hpp 2008-01-27 13:43:35 EST (Sun, 27 Jan 2008)
@@ -1270,6 +1270,19 @@
             state = state->next.p;
             continue;
          }
+ if((static_cast<re_brace*>(state)->index == -1)
+ || (static_cast<re_brace*>(state)->index == -2))
+ {
+ // skip past the zero width assertion:
+ state = static_cast<const re_jump*>(state->next.p)->alt.p->next.p;
+ continue;
+ }
+ if(static_cast<re_brace*>(state)->index == -3)
+ {
+ // Have to skip the leading jump state:
+ state = state->next.p->next.p;
+ continue;
+ }
          return;
       case syntax_element_endmark:
       case syntax_element_start_line:

Modified: trunk/boost/regex/v4/perl_matcher_non_recursive.hpp
==============================================================================
--- trunk/boost/regex/v4/perl_matcher_non_recursive.hpp (original)
+++ trunk/boost/regex/v4/perl_matcher_non_recursive.hpp 2008-01-27 13:43:35 EST (Sun, 27 Jan 2008)
@@ -1193,6 +1193,9 @@
          pstate = rep->next.p;
       }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip));
    }
+ // remember where we got to if this is a leading repeat:
+ if((rep->leading) && (count < rep->max))
+ restart = position;
    if(position == last)
    {
       // can't repeat any more, remove the pushed state:
@@ -1259,6 +1262,9 @@
          pstate = rep->next.p;
       }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip));
    }
+ // remember where we got to if this is a leading repeat:
+ if((rep->leading) && (count < rep->max))
+ restart = position;
    if(position == last)
    {
       // can't repeat any more, remove the pushed state:
@@ -1326,6 +1332,9 @@
          pstate = rep->next.p;
       }while((count < rep->max) && (position != last) && !can_start(*position, rep->_map, mask_skip));
    }
+ // remember where we got to if this is a leading repeat:
+ if((rep->leading) && (count < rep->max))
+ restart = position;
    if(position == last)
    {
       // can't repeat any more, remove the pushed state:


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