diff options
Diffstat (limited to '3rdParty/Boost/src/boost/regex/v4/perl_matcher_recursive.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/regex/v4/perl_matcher_recursive.hpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/3rdParty/Boost/src/boost/regex/v4/perl_matcher_recursive.hpp b/3rdParty/Boost/src/boost/regex/v4/perl_matcher_recursive.hpp index 07a1c20..8e0e182 100644 --- a/3rdParty/Boost/src/boost/regex/v4/perl_matcher_recursive.hpp +++ b/3rdParty/Boost/src/boost/regex/v4/perl_matcher_recursive.hpp @@ -641,7 +641,13 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_set_repeat() if(::boost::is_random_access_iterator<BidiIterator>::value) { BidiIterator end = position; - std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + // Move end forward by "desired", preferably without using distance or advance if we can + // as these can be slow for some iterator types. + std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::re_detail::distance(position, last); + if(desired >= len) + end = last; + else + std::advance(end, desired); BidiIterator origin(position); while((position != end) && map[static_cast<unsigned char>(traits_inst.translate(*position, icase))]) { @@ -731,7 +737,13 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_long_set_repeat() if(::boost::is_random_access_iterator<BidiIterator>::value) { BidiIterator end = position; - std::advance(end, (std::min)((std::size_t)::boost::re_detail::distance(position, last), desired)); + // Move end forward by "desired", preferably without using distance or advance if we can + // as these can be slow for some iterator types. + std::size_t len = (desired == (std::numeric_limits<std::size_t>::max)()) ? 0u : ::boost::re_detail::distance(position, last); + if(desired >= len) + end = last; + else + std::advance(end, desired); BidiIterator origin(position); while((position != end) && (position != re_is_set_member(position, last, set, re.get_data(), icase))) { |