Skip to content

Commit f57e71d

Browse files
authored
<regex>: Simplify matching of _N_if NFA nodes in leftmost-longest mode (#5405)
1 parent c5ed364 commit f57e71d

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

stl/inc/regex

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,26 +3198,15 @@ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Do_if(_Node_if* _Node) { // apply
31983198
}
31993199

32003200
// see if there is a longer match
3201-
_Tgt_state_t<_It> _Final = _Tgt_state;
3202-
auto _Final_len = _STD distance(_St._Cur, _Tgt_state._Cur);
32033201
for (;;) { // process one branch of if
32043202
_Node = _Node->_Child;
32053203
if (!_Node) {
32063204
break;
32073205
}
32083206

32093207
_Tgt_state = _St;
3210-
if (_Match_pat(_Node->_Next)) { // record match if it is longer
3211-
const auto _Len = _STD distance(_St._Cur, _Tgt_state._Cur);
3212-
if (_Final_len < _Len) { // memorize longest so far
3213-
_Final = _Tgt_state;
3214-
_Final_len = _Len;
3215-
}
3216-
}
3208+
(void) _Match_pat(_Node->_Next);
32173209
}
3218-
3219-
// set the input end to the longest match
3220-
_Tgt_state = _Final;
32213210
return true;
32223211
}
32233212

0 commit comments

Comments
 (0)