From 4cb79888fe4ecff7900ebdb84b3b2a38a87a3c22 Mon Sep 17 00:00:00 2001 From: Jake Bentvelzen Date: Sun, 27 Jan 2019 23:30:30 +1100 Subject: [PATCH] graphics: Clear mipmap map to avoid unnecessary allocation (#799) This change uses a pattern that Go 1.11+ compilers can optimize to a clear operation https://github.com/golang/go/blob/master/doc/go1.11.html#L447 --- image.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/image.go b/image.go index 715c10ff7..38eeca93a 100644 --- a/image.go +++ b/image.go @@ -112,7 +112,9 @@ func (m *mipmap) disposeMipmaps() { img.Dispose() } } - m.imgs = map[image.Rectangle][]*shareable.Image{} + for k := range m.imgs { + delete(m.imgs, k) + } } // Image represents a rectangle set of pixels.