| 141 | } |
| 142 | |
| 143 | func stringIndexPrefixFilter(prefix string, ignoreCase bool, minRequiredLength int) StringPrefixFilter { |
| 144 | if prefix == "" { |
| 145 | return nil |
| 146 | } |
| 147 | if ignoreCase && !isASCIIString(prefix) { |
| 148 | return nil |
| 149 | } |
| 150 | |
| 151 | return func(input string, startAt int) (candidateByteIndex int, ok bool) { |
| 152 | if !hasMinRequiredBytes(input, startAt, minRequiredLength) { |
| 153 | return 0, false |
| 154 | } |
| 155 | |
| 156 | var offset int |
| 157 | if ignoreCase { |
| 158 | offset = helpers.IndexStringIgnoreCaseASCII(input[startAt:], prefix) |
| 159 | } else { |
| 160 | offset = strings.Index(input[startAt:], prefix) |
| 161 | } |
| 162 | if offset < 0 { |
| 163 | return 0, false |
| 164 | } |
| 165 | return startAt + offset, true |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | func stringIndexPrefixesFilter(prefixes []string, ignoreCase bool, minRequiredLength int) StringPrefixFilter { |
| 170 | if len(prefixes) == 0 { |