From 1f4214012a612f2163b01930444d83712d99b5f9 Mon Sep 17 00:00:00 2001 From: Aryaz Eghbali <64126826+AryazE@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:00:49 +0100 Subject: [PATCH] Performance improvement (#1075) --- PathPlanning/WavefrontCPP/wavefront_coverage_path_planner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PathPlanning/WavefrontCPP/wavefront_coverage_path_planner.py b/PathPlanning/WavefrontCPP/wavefront_coverage_path_planner.py index 8968c54dcc..7e93caa8fb 100644 --- a/PathPlanning/WavefrontCPP/wavefront_coverage_path_planner.py +++ b/PathPlanning/WavefrontCPP/wavefront_coverage_path_planner.py @@ -64,7 +64,7 @@ def transform( is_visited = np.zeros_like(transform_matrix, dtype=bool) is_visited[src[0], src[1]] = True traversal_queue = [src] - calculated = [(src[0] - 1) * n_cols + src[1]] + calculated = set([(src[0] - 1) * n_cols + src[1]]) def is_valid_neighbor(g_i, g_j): return 0 <= g_i < n_rows and 0 <= g_j < n_cols \ @@ -86,7 +86,7 @@ def is_valid_neighbor(g_i, g_j): if not is_visited[ni][nj] \ and ((ni - 1) * n_cols + nj) not in calculated: traversal_queue.append((ni, nj)) - calculated.append((ni - 1) * n_cols + nj) + calculated.add((ni - 1) * n_cols + nj) return transform_matrix