for luuuup (micro optimisations)
This commit is contained in:
parent
05460a0491
commit
920be0d7c0
2 changed files with 6 additions and 7 deletions
|
@ -73,10 +73,8 @@ func (d *DrawDAG) Draw(screen *ebiten.Image, opts *ebiten.DrawImageOptions) {
|
||||||
stack = append(stack, p)
|
stack = append(stack, p)
|
||||||
}
|
}
|
||||||
// Unwind the stack, accumulating state along the way.
|
// Unwind the stack, accumulating state along the way.
|
||||||
for len(stack) > 0 {
|
for i := len(stack) - 1; i >= 0; i-- {
|
||||||
l1 := len(stack) - 1
|
p := stack[i]
|
||||||
p := stack[l1]
|
|
||||||
stack = stack[:l1]
|
|
||||||
if h, ok := p.(Hider); ok {
|
if h, ok := p.(Hider); ok {
|
||||||
st.hidden = st.hidden || h.Hidden()
|
st.hidden = st.hidden || h.Hidden()
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,8 +114,9 @@ func (g *Game) Parent(c interface{}) interface{} {
|
||||||
// PathRegister calls Register on every Registrar in the path between g and
|
// PathRegister calls Register on every Registrar in the path between g and
|
||||||
// parent (top-to-bottom, i.e. g first)
|
// parent (top-to-bottom, i.e. g first)
|
||||||
func (g *Game) PathRegister(component, parent interface{}) error {
|
func (g *Game) PathRegister(component, parent interface{}) error {
|
||||||
for _, p := range g.Path(parent) {
|
rp := g.ReversePath(parent)
|
||||||
if r, ok := p.(Registrar); ok {
|
for i := len(rp) - 1; i >= 0; i-- {
|
||||||
|
if r, ok := rp[i].(Registrar); ok {
|
||||||
if err := r.Register(component, parent); err != nil {
|
if err := r.Register(component, parent); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -125,7 +126,7 @@ func (g *Game) PathRegister(component, parent interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PathUnregister calls Unregister on every Registrar in the path between g and
|
// PathUnregister calls Unregister on every Registrar in the path between g and
|
||||||
// parent (bottom-to-top, i.e. parent first)
|
// parent (bottom-to-top, i.e. parent first).
|
||||||
func (g *Game) PathUnregister(component interface{}) {
|
func (g *Game) PathUnregister(component interface{}) {
|
||||||
for _, p := range g.ReversePath(component) {
|
for _, p := range g.ReversePath(component) {
|
||||||
if r, ok := p.(Registrar); ok {
|
if r, ok := p.(Registrar); ok {
|
||||||
|
|
Loading…
Reference in a new issue