@@ -46,6 +46,8 @@ func (e *Engine) FindIndices(haystack []byte) (start, end int, found bool) {
4646 return e .findIndicesDigitPrefilter (haystack )
4747 case UseAhoCorasick :
4848 return e .findIndicesAhoCorasick (haystack )
49+ case UseMultilineReverseSuffix :
50+ return e .findIndicesMultilineReverseSuffix (haystack )
4951 default :
5052 return e .findIndicesNFA (haystack )
5153 }
@@ -86,6 +88,8 @@ func (e *Engine) FindIndicesAt(haystack []byte, at int) (start, end int, found b
8688 return e .findIndicesDigitPrefilterAt (haystack , at )
8789 case UseAhoCorasick :
8890 return e .findIndicesAhoCorasickAt (haystack , at )
91+ case UseMultilineReverseSuffix :
92+ return e .findIndicesMultilineReverseSuffixAt (haystack , at )
8993 default :
9094 return e .findIndicesNFAAt (haystack , at )
9195 }
@@ -436,6 +440,24 @@ func (e *Engine) findIndicesReverseInnerAt(haystack []byte, at int) (int, int, b
436440 return e .reverseInnerSearcher .FindIndicesAt (haystack , at )
437441}
438442
443+ // findIndicesMultilineReverseSuffix searches using multiline suffix optimization - zero alloc.
444+ func (e * Engine ) findIndicesMultilineReverseSuffix (haystack []byte ) (int , int , bool ) {
445+ if e .multilineReverseSuffixSearcher == nil {
446+ return e .findIndicesNFA (haystack )
447+ }
448+ atomic .AddUint64 (& e .stats .DFASearches , 1 )
449+ return e .multilineReverseSuffixSearcher .FindIndicesAt (haystack , 0 )
450+ }
451+
452+ // findIndicesMultilineReverseSuffixAt searches using multiline suffix optimization from position - zero alloc.
453+ func (e * Engine ) findIndicesMultilineReverseSuffixAt (haystack []byte , at int ) (int , int , bool ) {
454+ if e .multilineReverseSuffixSearcher == nil {
455+ return e .findIndicesNFAAt (haystack , at )
456+ }
457+ atomic .AddUint64 (& e .stats .DFASearches , 1 )
458+ return e .multilineReverseSuffixSearcher .FindIndicesAt (haystack , at )
459+ }
460+
439461// findIndicesBoundedBacktracker searches using bounded backtracker - zero alloc.
440462// Thread-safe: uses pooled state.
441463func (e * Engine ) findIndicesBoundedBacktracker (haystack []byte ) (int , int , bool ) {
0 commit comments