v14-0005-Remove-unnecessary-check-from-Fisher-Yates-imple.patch
application/octet-stream
Filename: v14-0005-Remove-unnecessary-check-from-Fisher-Yates-imple.patch
Type: application/octet-stream
Part: 3
Patch
Format: format-patch
Series: patch v14-0005
Subject: Remove unnecessary check from Fisher-Yates implementation
| File | + | − |
|---|---|---|
| src/backend/optimizer/geqo/geqo_recombination.c | 1 | 3 |
From 4f4c480a5f1342a03cbb3d525b5382d75d9054bb Mon Sep 17 00:00:00 2001
From: Jelte Fennema <jelte.fennema@microsoft.com>
Date: Fri, 3 Mar 2023 15:27:21 +0100
Subject: [PATCH v14 5/5] Remove unnecessary check from Fisher-Yates
implementation
Andrey Borodin pointed out that the "undefined data check" was
unnecessary for Fisher-Yates implementations when the data that was
fetched was known to be initialized. There was one such place in the
codebase, so this removes the check there.
---
src/backend/optimizer/geqo/geqo_recombination.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/backend/optimizer/geqo/geqo_recombination.c b/src/backend/optimizer/geqo/geqo_recombination.c
index a5d3e47ad11..53bf0cc0a42 100644
--- a/src/backend/optimizer/geqo/geqo_recombination.c
+++ b/src/backend/optimizer/geqo/geqo_recombination.c
@@ -51,9 +51,7 @@ init_tour(PlannerInfo *root, Gene *tour, int num_gene)
for (i = 1; i < num_gene; i++)
{
j = geqo_randint(root, i, 0);
- /* i != j check avoids fetching uninitialized array element */
- if (i != j)
- tour[i] = tour[j];
+ tour[i] = tour[j];
tour[j] = (Gene) (i + 1);
}
}
--
2.34.1