shorten preorderWalk

This commit is contained in:
Josh Deprez 2021-09-23 12:14:03 +10:00
parent 80a0132c39
commit eed623647c

View file

@ -181,14 +181,12 @@ func preorderWalk(component, parent interface{}, visit func(component, parent in
if err := visit(component, parent); err != nil { if err := visit(component, parent); err != nil {
return err return err
} }
sc, ok := component.(Scanner) if sc, ok := component.(Scanner); ok {
if !ok { return sc.Scan(func(c interface{}) error {
return nil
}
scv := func(c interface{}) error {
return preorderWalk(c, component, visit) return preorderWalk(c, component, visit)
})
} }
return sc.Scan(scv) return nil
} }
// PostorderWalk calls visit with every component and its parent, reachable from // PostorderWalk calls visit with every component and its parent, reachable from