Skip to content

Commit 18450eb

Browse files
committed
Fix optimizer for in []int
1 parent 4f8a827 commit 18450eb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

optimizer/optimizer.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ func (*inArray) Exit(node *Node) {
4444
switch n := (*node).(type) {
4545
case *BinaryNode:
4646
if n.Operator == "in" || n.Operator == "not in" {
47-
t := n.Left.GetType()
48-
if t == nil || n.Left.GetType().Kind() != reflect.Int {
49-
// This optimization can be only performed if left side is int type,
50-
// as runtime.in func uses reflect.Map.MapIndex and keys of map must,
51-
// be same as checked value type.
52-
return
53-
}
5447
if array, ok := n.Right.(*ArrayNode); ok {
5548
if len(array.Nodes) > 0 {
49+
t := n.Left.GetType()
50+
if t == nil || t.Kind() != reflect.Int {
51+
// This optimization can be only performed if left side is int type,
52+
// as runtime.in func uses reflect.Map.MapIndex and keys of map must,
53+
// be same as checked value type.
54+
goto string
55+
}
5656

5757
for _, a := range array.Nodes {
5858
if _, ok := a.(*IntegerNode); !ok {

0 commit comments

Comments
 (0)