Skip to content

Commit

Permalink
Avoid allocations on suface view scale
Browse files Browse the repository at this point in the history
  • Loading branch information
JD557 committed Nov 26, 2023
1 parent 3e7710f commit bdff208
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bdff208

Please sign in to comment.