(set syntax.FixedDistanceSet)
| 81 | } |
| 82 | |
| 83 | func newASCIISetStringScanner(set syntax.FixedDistanceSet) (asciiSetStringScanner, bool) { |
| 84 | if set.Negated || set.Distance < 0 { |
| 85 | return asciiSetStringScanner{}, false |
| 86 | } |
| 87 | if set.Range != nil { |
| 88 | if set.Range.First < 0 || set.Range.Last > utf8.RuneSelf-1 { |
| 89 | return asciiSetStringScanner{}, false |
| 90 | } |
| 91 | return asciiSetStringScanner{ |
| 92 | first: byte(set.Range.First), |
| 93 | last: byte(set.Range.Last), |
| 94 | useRange: true, |
| 95 | distance: set.Distance, |
| 96 | }, true |
| 97 | } |
| 98 | if len(set.Chars) == 0 { |
| 99 | return asciiSetStringScanner{}, false |
| 100 | } |
| 101 | chars := make([]byte, len(set.Chars)) |
| 102 | for i, ch := range set.Chars { |
| 103 | if ch < 0 || ch > utf8.RuneSelf-1 { |
| 104 | return asciiSetStringScanner{}, false |
| 105 | } |
| 106 | chars[i] = byte(ch) |
| 107 | } |
| 108 | return asciiSetStringScanner{chars: string(chars), distance: set.Distance}, true |
| 109 | } |
| 110 | |
| 111 | func stringFixedDistanceSetFilter(set syntax.FixedDistanceSet, minRequiredLength int) StringPrefixFilter { |
| 112 | scanner, ok := newASCIISetStringScanner(set) |
no outgoing calls
no test coverage detected