|
|
|
@ -10,7 +10,7 @@ type startBytesThree struct {
|
|
|
|
|
byte3 byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *startBytesThree) NextCandidate(_ *prefilterState, haystack []byte, at int) (interface{}, candidateType) {
|
|
|
|
|
func (s *startBytesThree) NextCandidate(_ *prefilterState, haystack []byte, at int) (any, candidateType) {
|
|
|
|
|
for i, b := range haystack[at:] {
|
|
|
|
|
if s.byte1 == b || s.byte2 == b || s.byte3 == b {
|
|
|
|
|
return at + i, possibleStartOfMatchCandidate
|
|
|
|
@ -44,7 +44,7 @@ type startBytesTwo struct {
|
|
|
|
|
byte2 byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *startBytesTwo) NextCandidate(_ *prefilterState, haystack []byte, at int) (interface{}, candidateType) {
|
|
|
|
|
func (s *startBytesTwo) NextCandidate(_ *prefilterState, haystack []byte, at int) (any, candidateType) {
|
|
|
|
|
for i, b := range haystack[at:] {
|
|
|
|
|
if s.byte1 == b || s.byte2 == b {
|
|
|
|
|
return at + i, possibleStartOfMatchCandidate
|
|
|
|
@ -77,7 +77,7 @@ type startBytesOne struct {
|
|
|
|
|
byte1 byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *startBytesOne) NextCandidate(_ *prefilterState, haystack []byte, at int) (interface{}, candidateType) {
|
|
|
|
|
func (s *startBytesOne) NextCandidate(_ *prefilterState, haystack []byte, at int) (any, candidateType) {
|
|
|
|
|
for i, b := range haystack[at:] {
|
|
|
|
|
if s.byte1 == b {
|
|
|
|
|
return at + i, possibleStartOfMatchCandidate
|
|
|
|
@ -192,7 +192,7 @@ type rareBytesOne struct {
|
|
|
|
|
offset rareByteOffset
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *rareBytesOne) NextCandidate(state *prefilterState, haystack []byte, at int) (interface{}, candidateType) {
|
|
|
|
|
func (r *rareBytesOne) NextCandidate(state *prefilterState, haystack []byte, at int) (any, candidateType) {
|
|
|
|
|
for i, b := range haystack[at:] {
|
|
|
|
|
if r.byte1 == b {
|
|
|
|
|
pos := at + i
|
|
|
|
@ -237,7 +237,7 @@ type rareBytesTwo struct {
|
|
|
|
|
byte2 byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *rareBytesTwo) NextCandidate(state *prefilterState, haystack []byte, at int) (interface{}, candidateType) {
|
|
|
|
|
func (r *rareBytesTwo) NextCandidate(state *prefilterState, haystack []byte, at int) (any, candidateType) {
|
|
|
|
|
for i, b := range haystack[at:] {
|
|
|
|
|
if r.byte1 == b || r.byte2 == b {
|
|
|
|
|
pos := at + i
|
|
|
|
@ -283,7 +283,7 @@ type rareBytesThree struct {
|
|
|
|
|
byte3 byte
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (r *rareBytesThree) NextCandidate(state *prefilterState, haystack []byte, at int) (interface{}, candidateType) {
|
|
|
|
|
func (r *rareBytesThree) NextCandidate(state *prefilterState, haystack []byte, at int) (any, candidateType) {
|
|
|
|
|
for i, b := range haystack[at:] {
|
|
|
|
|
if r.byte1 == b || r.byte2 == b || r.byte3 == b {
|
|
|
|
|
pos := at + i
|
|
|
|
@ -577,14 +577,14 @@ const (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type prefilter interface {
|
|
|
|
|
NextCandidate(state *prefilterState, haystack []byte, at int) (interface{}, candidateType)
|
|
|
|
|
NextCandidate(state *prefilterState, haystack []byte, at int) (any, candidateType)
|
|
|
|
|
HeapBytes() int
|
|
|
|
|
ReportsFalsePositives() bool
|
|
|
|
|
LooksForNonStartOfMatch() bool
|
|
|
|
|
clone() prefilter
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func nextPrefilter(state *prefilterState, prefilter prefilter, haystack []byte, at int) (interface{}, candidateType) {
|
|
|
|
|
func nextPrefilter(state *prefilterState, prefilter prefilter, haystack []byte, at int) (any, candidateType) {
|
|
|
|
|
candidate, typ := prefilter.NextCandidate(state, haystack, at)
|
|
|
|
|
|
|
|
|
|
switch typ {
|
|
|
|
|