internal/restorable: refactoring: remove lastTarget

This didn't improve performance very much. Rather, this made the code
a little hard to read and could have a potential issue.
This commit is contained in:
Hajime Hoshi 2024-09-08 16:03:56 +09:00
parent 167c3435f7
commit 20f8df7fc1

View File

@ -62,7 +62,6 @@ func AlwaysReadPixelsFromGPU() bool {
type images struct { type images struct {
images map[*Image]struct{} images map[*Image]struct{}
shaders map[*Shader]struct{} shaders map[*Shader]struct{}
lastTarget *Image
contextLost atomic.Bool contextLost atomic.Bool
} }
@ -157,7 +156,6 @@ func (i *images) removeShader(shader *Shader) {
// resolveStaleImages resolves stale images. // resolveStaleImages resolves stale images.
func (i *images) resolveStaleImages(graphicsDriver graphicsdriver.Graphics) error { func (i *images) resolveStaleImages(graphicsDriver graphicsdriver.Graphics) error {
i.lastTarget = nil
for img := range i.images { for img := range i.images {
if err := img.resolveStale(graphicsDriver); err != nil { if err := img.resolveStale(graphicsDriver); err != nil {
return err return err
@ -174,10 +172,6 @@ func (i *images) makeStaleIfDependingOn(target *Image) {
if target == nil { if target == nil {
panic("restorable: target must not be nil at makeStaleIfDependingOn") panic("restorable: target must not be nil at makeStaleIfDependingOn")
} }
if i.lastTarget == target {
return
}
i.lastTarget = target
for img := range i.images { for img := range i.images {
img.makeStaleIfDependingOn(target) img.makeStaleIfDependingOn(target)
} }