From 8e46856468d631e65efe8b06c8fb09bd1eeb0cfa Mon Sep 17 00:00:00 2001
From: Stepan Neretin <sndcppg@gmail.com>
Date: Sun, 8 Sep 2024 15:44:10 +0700
Subject: [PATCH v2 07/10] Introduce a sorting template for float8 arrays in
 geo_spgist.c to boost performance.

---
 src/backend/utils/adt/geo_spgist.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/backend/utils/adt/geo_spgist.c b/src/backend/utils/adt/geo_spgist.c
index 51378dca5b..fa0a753fa4 100644
--- a/src/backend/utils/adt/geo_spgist.c
+++ b/src/backend/utils/adt/geo_spgist.c
@@ -100,6 +100,17 @@ compareDoubles(const void *a, const void *b)
 	return (x > y) ? 1 : -1;
 }
 
+ /*
++ * Instantiating a Sorting Template for float8 Arrays
++ * enhancing speed performance.
++ */
+#define ST_SORT sort_float8_arr
+#define ST_ELEMENT_TYPE float8
+#define ST_COMPARE(a, b) compareDoubles(a, b)
+#define ST_SCOPE static
+#define ST_DEFINE
+#include <lib/sort_template.h>
+
 typedef struct
 {
 	float8		low;
-- 
2.43.0

