(input string, startAt int)
| 65 | } |
| 66 | |
| 67 | func (s *equalASCIIPrefixSearch) shouldUseString(input string, startAt int) bool { |
| 68 | // Distinct first bytes already use strings.Index per prefix, which is |
| 69 | // especially effective for a small number of alternatives on sparse input. |
| 70 | if !s.sharedFirst || startAt < 0 || startAt > len(input)-prefixSearchSampleSize { |
| 71 | return false |
| 72 | } |
| 73 | candidates := 0 |
| 74 | for i := startAt; i < startAt+prefixSearchSampleSize; i++ { |
| 75 | ch := input[i] |
| 76 | if ch < 128 && s.masks[ch]&s.starts != 0 { |
| 77 | candidates++ |
| 78 | } |
| 79 | } |
| 80 | return candidates >= prefixSearchSampleSize/4 |
| 81 | } |
| 82 | |
| 83 | // indexRunes returns an absolute rune index, or -1. A non-ASCII rune (including |
| 84 | // invalid rune values accepted by rune APIs) cannot occur in these prefixes and |
no outgoing calls