From daac47133bad7e841979a7fc0df5788769563ded Mon Sep 17 00:00:00 2001 From: Nox Liu Date: Tue, 19 Nov 2024 00:33:26 +0800 Subject: [PATCH] Optimize: Use simple way to check if game still active. Instead of by loop. --- .../tic-tac-toe/programs/tic-tac-toe/src/state/game.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/programs/tic-tac-toe/programs/tic-tac-toe/src/state/game.rs b/docs/programs/tic-tac-toe/programs/tic-tac-toe/src/state/game.rs index cf3acb0c5f..85118b739c 100644 --- a/docs/programs/tic-tac-toe/programs/tic-tac-toe/src/state/game.rs +++ b/docs/programs/tic-tac-toe/programs/tic-tac-toe/src/state/game.rs @@ -96,12 +96,8 @@ impl Game { // reaching this code means the game has not been won, // so if there are unfilled tiles left, it's still active - for row in 0..=2 { - for column in 0..=2 { - if self.board[row][column].is_none() { - return; - } - } + if self.turn < 9 { + return; } // game has not been won