Skip to content

Commit

Permalink
Avoid unnecessary bounds check
Browse files Browse the repository at this point in the history
  • Loading branch information
JD557 committed Nov 2, 2024
1 parent 9c31f70 commit f536cc9
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ trait Plane extends Function2[Int, Int, Color] { outer =>
new Plane {
def getPixel(x: Int, y: Int): Color = {
val c1 = outer.getPixel(x, y)
if (x >= 0 && y >= 0 && x < that.width && y < that.height) {
val c2 = that.unsafeGetPixel(x, y)
f(c1, c2)
} else c1
// This plane is clipped into a surface view, so x and y will always be in bounds
val c2 = that.unsafeGetPixel(x, y)
f(c1, c2)
}
},
width = that.width,
Expand Down

0 comments on commit f536cc9

Please sign in to comment.