mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
6c89137ee1
Bumps [github.com/expr-lang/expr](https://github.com/expr-lang/expr) from 1.16.9 to 1.17.0. - [Release notes](https://github.com/expr-lang/expr/releases) - [Commits](https://github.com/expr-lang/expr/compare/v1.16.9...v1.17.0) --- updated-dependencies: - dependency-name: github.com/expr-lang/expr dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
26 lines
535 B
Go
26 lines
535 B
Go
package optimizer
|
|
|
|
import (
|
|
. "github.com/expr-lang/expr/ast"
|
|
)
|
|
|
|
type sumMap struct{}
|
|
|
|
func (*sumMap) Visit(node *Node) {
|
|
if sumBuiltin, ok := (*node).(*BuiltinNode); ok &&
|
|
sumBuiltin.Name == "sum" &&
|
|
len(sumBuiltin.Arguments) == 1 {
|
|
if mapBuiltin, ok := sumBuiltin.Arguments[0].(*BuiltinNode); ok &&
|
|
mapBuiltin.Name == "map" &&
|
|
len(mapBuiltin.Arguments) == 2 {
|
|
patchCopyType(node, &BuiltinNode{
|
|
Name: "sum",
|
|
Arguments: []Node{
|
|
mapBuiltin.Arguments[0],
|
|
mapBuiltin.Arguments[1],
|
|
},
|
|
})
|
|
}
|
|
}
|
|
}
|