shorten preorderWalk
This commit is contained in:
parent
80a0132c39
commit
eed623647c
1 changed files with 5 additions and 7 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue