Skip to content

Commit

Permalink
Avoid ranges on AABB
Browse files Browse the repository at this point in the history
  • Loading branch information
JD557 committed Nov 23, 2024
1 parent 74c1ac6 commit a4ed196
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,17 @@ final case class AxisAlignedBoundingBox(
*
* @param f side effect, receiving (x, y) points
*/
def foreach(f: (Int, Int) => Unit): Unit =
for {
y <- (y1 until y2).iterator
x <- (x1 until x2).iterator
} f(x, y)
def foreach(f: (Int, Int) => Unit): Unit = {
var y = y1
while (y < y2) {
var x = x1
while (x < x2) {
f(x, y)
x = x + 1
}
y = y + 1
}
}
}

object AxisAlignedBoundingBox {
Expand Down

0 comments on commit a4ed196

Please sign in to comment.