This commit is contained in:
Adnan Hajdarevic 2021-04-03 18:01:13 +02:00
parent e329b6d9ff
commit 568c711625
138 changed files with 22876 additions and 90497 deletions

41
vendor/github.com/antonmedv/expr/optimizer/in_range.go generated vendored Normal file
View file

@ -0,0 +1,41 @@
package optimizer
import (
. "github.com/antonmedv/expr/ast"
)
type inRange struct{}
func (*inRange) Enter(*Node) {}
func (*inRange) Exit(node *Node) {
switch n := (*node).(type) {
case *BinaryNode:
if n.Operator == "in" || n.Operator == "not in" {
if rng, ok := n.Right.(*BinaryNode); ok && rng.Operator == ".." {
if from, ok := rng.Left.(*IntegerNode); ok {
if to, ok := rng.Right.(*IntegerNode); ok {
Patch(node, &BinaryNode{
Operator: "and",
Left: &BinaryNode{
Operator: ">=",
Left: n.Left,
Right: from,
},
Right: &BinaryNode{
Operator: "<=",
Left: n.Left,
Right: to,
},
})
if n.Operator == "not in" {
Patch(node, &UnaryNode{
Operator: "not",
Node: *node,
})
}
}
}
}
}
}
}