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