MCPcopy Create free account
hub / github.com/dlclark/regexp2 / stringFixedDistanceCandidateStart

Function stringFixedDistanceCandidateStart

stringprefixfilter.go:384–397  ·  view source on GitHub ↗
(input string, startAt, byteIndex, distance int)

Source from the content-addressed store, hash-verified

382}
383
384func stringFixedDistanceCandidateStart(input string, startAt, byteIndex, distance int) (int, bool) {
385 candidateByteIndex := byteIndex
386 for i := 0; i < distance; i++ {
387 if candidateByteIndex <= startAt {
388 return 0, false
389 }
390 _, size := utf8.DecodeLastRuneInString(input[:candidateByteIndex])
391 if size == 0 {
392 return 0, false
393 }
394 candidateByteIndex -= size
395 }
396 return candidateByteIndex, true
397}
398
399func (re *Regexp) findStringPrefixCandidate(input string, startAt int) (candidateByteIndex int, ok bool) {
400 if re.stringPrefixFilter == nil || re.RightToLeft() {

Calls

no outgoing calls

Tested by

no test coverage detected