(set syntax.FixedDistanceSet)
| 68 | } |
| 69 | |
| 70 | func newASCIISetStringScanner(set syntax.FixedDistanceSet) (asciiSetStringScanner, bool) { |
| 71 | if set.Negated || set.Distance < 0 { |
| 72 | return asciiSetStringScanner{}, false |
| 73 | } |
| 74 | if set.Range != nil { |
| 75 | if set.Range.First < 0 || set.Range.Last > utf8.RuneSelf-1 { |
| 76 | return asciiSetStringScanner{}, false |
| 77 | } |
| 78 | return asciiSetStringScanner{ |
| 79 | first: byte(set.Range.First), |
| 80 | last: byte(set.Range.Last), |
| 81 | useRange: true, |
| 82 | distance: set.Distance, |
| 83 | }, true |
| 84 | } |
| 85 | if len(set.Chars) == 0 { |
| 86 | return asciiSetStringScanner{}, false |
| 87 | } |
| 88 | chars := make([]byte, len(set.Chars)) |
| 89 | for i, ch := range set.Chars { |
| 90 | if ch < 0 || ch > utf8.RuneSelf-1 { |
| 91 | return asciiSetStringScanner{}, false |
| 92 | } |
| 93 | chars[i] = byte(ch) |
| 94 | } |
| 95 | return asciiSetStringScanner{chars: string(chars), distance: set.Distance}, true |
| 96 | } |
| 97 | |
| 98 | func stringFixedDistanceSetFilter(set syntax.FixedDistanceSet, minRequiredLength int) StringPrefixFilter { |
| 99 | scanner, ok := newASCIISetStringScanner(set) |
no outgoing calls
no test coverage detected