summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/board.cpp b/board.cpp
index 91655dc..bd56f8a 100644
--- a/board.cpp
+++ b/board.cpp
@@ -160,15 +160,13 @@ const vector<int>& Board::getEdgeCells() const {
Bounds Board::computeBounds() const {
Bounds bounds;
- for (int y = 1; y < BSZ - 1; y++) {
- for (int x = 1; x < BSZ - 1; x++) {
- int idx = BSZ * y + x;
- if (bd[idx] != 0 || checkEdge(idx)) {
- bounds.left = min(bounds.left, x);
- bounds.right = max(bounds.right, x);
- bounds.top = min(bounds.top, y);
- bounds.bottom = max(bounds.bottom, y);
- }
+ for (int idx : edgeCells) {
+ int x = idx % BSZ, y = idx / BSZ;
+ if (bd[idx] != 0 || checkEdge(idx)) {
+ bounds.left = min(bounds.left, x);
+ bounds.right = max(bounds.right, x);
+ bounds.top = min(bounds.top, y);
+ bounds.bottom = max(bounds.bottom, y);
}
}