Use slice for range in Drawer.Dirty(), to improve performance
@@ -25,6 +25,7 @@ type Drawer struct {
Picture Picture
targets map[Target]*drawerTarget
+ allTargets []*drawerTarget
inited bool
}
@@ -46,7 +47,7 @@ func (d *Drawer) lazyInit() {
func (d *Drawer) Dirty() {
d.lazyInit()
- for _, t := range d.targets {
+ for _, t := range d.allTargets {
t.clean = false
}
}
@@ -68,6 +69,7 @@ func (d *Drawer) Draw(t Target) {
pics: make(map[Picture]TargetPicture),
}
d.targets[t] = dt
+ d.allTargets = append(d.allTargets, dt)
}
if dt.tris == nil {
