(node *Node)
| 14 | type countThreshold struct{} |
| 15 | |
| 16 | func (*countThreshold) Visit(node *Node) { |
| 17 | binary, ok := (*node).(*BinaryNode) |
| 18 | if !ok { |
| 19 | return |
| 20 | } |
| 21 | |
| 22 | count, ok := binary.Left.(*BuiltinNode) |
| 23 | if !ok || count.Name != "count" || len(count.Arguments) != 2 { |
| 24 | return |
| 25 | } |
| 26 | |
| 27 | integer, ok := binary.Right.(*IntegerNode) |
| 28 | if !ok || integer.Value < 0 { |
| 29 | return |
| 30 | } |
| 31 | |
| 32 | var threshold int |
| 33 | switch binary.Operator { |
| 34 | case ">": |
| 35 | threshold = integer.Value + 1 |
| 36 | case ">=": |
| 37 | threshold = integer.Value |
| 38 | case "<": |
| 39 | threshold = integer.Value |
| 40 | case "<=": |
| 41 | threshold = integer.Value + 1 |
| 42 | default: |
| 43 | return |
| 44 | } |
| 45 | |
| 46 | // Skip if threshold is 0 or 1 (handled by count_any optimizer) |
| 47 | if threshold <= 1 { |
| 48 | return |
| 49 | } |
| 50 | |
| 51 | // Set threshold on the count node for early termination |
| 52 | // The original comparison remains unchanged |
| 53 | count.Threshold = &threshold |
| 54 | } |
nothing calls this directly
no outgoing calls
no test coverage detected