From bdff208ac8ed5224532bbd41438cf74646f6e26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Costa?= Date: Sun, 26 Nov 2023 17:50:40 +0100 Subject: [PATCH] Avoid allocations on suface view scale --- .../main/scala/eu/joaocosta/minart/graphics/SurfaceView.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/shared/src/main/scala/eu/joaocosta/minart/graphics/SurfaceView.scala b/core/shared/src/main/scala/eu/joaocosta/minart/graphics/SurfaceView.scala index 72ee1f78..bea5eb8f 100644 --- a/core/shared/src/main/scala/eu/joaocosta/minart/graphics/SurfaceView.scala +++ b/core/shared/src/main/scala/eu/joaocosta/minart/graphics/SurfaceView.scala @@ -90,7 +90,8 @@ final case class SurfaceView(plane: Plane, width: Int, height: Int) extends Surf /** Scales a surface. */ def scale(sx: Double, sy: Double): SurfaceView = - copy(plane = plane.scale(sx, sy), width = (width * sx).toInt, height = (height * sy).toInt) + if (sx == 1.0 && sy == 1.0) this + else copy(plane = plane.scale(sx, sy), width = (width * sx).toInt, height = (height * sy).toInt) /** Scales a surface. */ def scale(s: Double): SurfaceView = scale(s, s)