@@ -490,49 +490,52 @@ impl Core {
490490 // we know we aren't going to use the lazy DFA. So we do a config check
491491 // up front, which is in practice the only way we won't try to use the
492492 // DFA.
493- let ( nfarev, hybrid, dfa) =
494- if !info. config ( ) . get_hybrid ( ) && !info. config ( ) . get_dfa ( ) {
495- ( None , wrappers:: Hybrid :: none ( ) , wrappers:: DFA :: none ( ) )
493+ let ( nfarev, hybrid, dfa) = if !info. config ( ) . get_hybrid ( )
494+ && !info. config ( ) . get_dfa ( )
495+ // With look-arounds, the lazy DFA and dense DFA would fail to build
496+ || nfa. lookaround_count ( ) > 0
497+ {
498+ ( None , wrappers:: Hybrid :: none ( ) , wrappers:: DFA :: none ( ) )
499+ } else {
500+ // FIXME: Technically, we don't quite yet KNOW that we need
501+ // a reverse NFA. It's possible for the DFAs below to both
502+ // fail to build just based on the forward NFA. In which case,
503+ // building the reverse NFA was totally wasted work. But...
504+ // fixing this requires breaking DFA construction apart into
505+ // two pieces: one for the forward part and another for the
506+ // reverse part. Quite annoying. Making it worse, when building
507+ // both DFAs fails, it's quite likely that the NFA is large and
508+ // that it will take quite some time to build the reverse NFA
509+ // too. So... it's really probably worth it to do this!
510+ let nfarev = thompson:: Compiler :: new ( )
511+ // Currently, reverse NFAs don't support capturing groups,
512+ // so we MUST disable them. But even if we didn't have to,
513+ // we would, because nothing in this crate does anything
514+ // useful with capturing groups in reverse. And of course,
515+ // the lazy DFA ignores capturing groups in all cases.
516+ . configure (
517+ thompson_config
518+ . clone ( )
519+ . which_captures ( WhichCaptures :: None )
520+ . reverse ( true ) ,
521+ )
522+ . build_many_from_hir ( hirs)
523+ . map_err ( BuildError :: nfa) ?;
524+ let dfa = if !info. config ( ) . get_dfa ( ) {
525+ wrappers:: DFA :: none ( )
496526 } else {
497- // FIXME: Technically, we don't quite yet KNOW that we need
498- // a reverse NFA. It's possible for the DFAs below to both
499- // fail to build just based on the forward NFA. In which case,
500- // building the reverse NFA was totally wasted work. But...
501- // fixing this requires breaking DFA construction apart into
502- // two pieces: one for the forward part and another for the
503- // reverse part. Quite annoying. Making it worse, when building
504- // both DFAs fails, it's quite likely that the NFA is large and
505- // that it will take quite some time to build the reverse NFA
506- // too. So... it's really probably worth it to do this!
507- let nfarev = thompson:: Compiler :: new ( )
508- // Currently, reverse NFAs don't support capturing groups,
509- // so we MUST disable them. But even if we didn't have to,
510- // we would, because nothing in this crate does anything
511- // useful with capturing groups in reverse. And of course,
512- // the lazy DFA ignores capturing groups in all cases.
513- . configure (
514- thompson_config
515- . clone ( )
516- . which_captures ( WhichCaptures :: None )
517- . reverse ( true ) ,
518- )
519- . build_many_from_hir ( hirs)
520- . map_err ( BuildError :: nfa) ?;
521- let dfa = if !info. config ( ) . get_dfa ( ) {
522- wrappers:: DFA :: none ( )
523- } else {
524- wrappers:: DFA :: new ( & info, pre. clone ( ) , & nfa, & nfarev)
525- } ;
526- let hybrid = if !info. config ( ) . get_hybrid ( ) {
527- wrappers:: Hybrid :: none ( )
528- } else if dfa. is_some ( ) {
529- debug ! ( "skipping lazy DFA because we have a full DFA" ) ;
530- wrappers:: Hybrid :: none ( )
531- } else {
532- wrappers:: Hybrid :: new ( & info, pre. clone ( ) , & nfa, & nfarev)
533- } ;
534- ( Some ( nfarev) , hybrid, dfa)
527+ wrappers:: DFA :: new ( & info, pre. clone ( ) , & nfa, & nfarev)
535528 } ;
529+ let hybrid = if !info. config ( ) . get_hybrid ( ) {
530+ wrappers:: Hybrid :: none ( )
531+ } else if dfa. is_some ( ) {
532+ debug ! ( "skipping lazy DFA because we have a full DFA" ) ;
533+ wrappers:: Hybrid :: none ( )
534+ } else {
535+ wrappers:: Hybrid :: new ( & info, pre. clone ( ) , & nfa, & nfarev)
536+ } ;
537+ ( Some ( nfarev) , hybrid, dfa)
538+ } ;
536539 Ok ( Core {
537540 info,
538541 pre,
0 commit comments