From 29f883feeec344960b798dca6c1374261b957296 Mon Sep 17 00:00:00 2001
From: Pierre-Emmanuel Viel
Date: Sun, 17 May 2020 00:06:47 +0200
Subject: [PATCH] Optim: test that could be done once has been extracted from
the loop
---
.../opencv2/flann/kdtree_single_index.h | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/modules/flann/include/opencv2/flann/kdtree_single_index.h b/modules/flann/include/opencv2/flann/kdtree_single_index.h
index fa38f9f1a2..e03226bd75 100644
--- a/modules/flann/include/opencv2/flann/kdtree_single_index.h
+++ b/modules/flann/include/opencv2/flann/kdtree_single_index.h
@@ -548,11 +548,19 @@ private:
/* If this is a leaf node, then do check and return. */
if ((node->child1 == NULL)&&(node->child2 == NULL)) {
DistanceType worst_dist = result_set.worstDist();
- for (int i=node->left; iright; ++i) {
- int index = reorder_ ? i : vind_[i];
- DistanceType dist = distance_(vec, data_[index], dim_, worst_dist);
- if (distleft; iright; ++i) {
+ DistanceType dist = distance_(vec, data_[i], dim_, worst_dist);
+ if (distleft; iright; ++i) {
+ DistanceType dist = distance_(vec, data_[vind_[i]], dim_, worst_dist);
+ if (dist