From 0bfc4cd0687db67a4f0aa852f2601f22a8c0ef21 Mon Sep 17 00:00:00 2001
From: faiface <faiface@ksp.sk>
Date: Wed, 12 Apr 2017 16:18:25 +0200
Subject: [PATCH] minor optimization in Sprite

---
 sprite.go | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/sprite.go b/sprite.go
index 37305a8..9b08e51 100644
--- a/sprite.go
+++ b/sprite.go
@@ -58,8 +58,10 @@ func (s *Sprite) Frame() Rect {
 // Note, that this has nothing to do with BasicTarget's SetMatrix method. This only affects this
 // Sprite and is usable with any Target.
 func (s *Sprite) SetMatrix(matrix Matrix) {
-	s.matrix = matrix
-	s.calcData()
+	if s.matrix != matrix {
+		s.matrix = matrix
+		s.calcData()
+	}
 }
 
 // Matrix returns the currently set Matrix.
@@ -73,8 +75,11 @@ func (s *Sprite) Matrix() Matrix {
 // Note, that this has nothing to do with BasicTarget's SetColorMask method. This only affects this
 // Sprite and is usable with any Target.
 func (s *Sprite) SetColorMask(mask color.Color) {
-	s.mask = ToRGBA(mask)
-	s.calcData()
+	rgba := ToRGBA(mask)
+	if s.mask != rgba {
+		s.mask = ToRGBA(mask)
+		s.calcData()
+	}
 }
 
 // ColorMask returns the currently set color mask.
-- 
GitLab