[PATCH 1/3] Introduce helper variable in spgquadtreeproc.c

From: "Matwey V(dot) Kornilov" <matwey(dot)kornilov(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: "Matwey V(dot) Kornilov" <matwey(dot)kornilov(at)gmail(dot)com>, akorotkov(at)postgresql(dot)org, teodor(at)postgrespro(dot)ru
Subject: [PATCH 1/3] Introduce helper variable in spgquadtreeproc.c
Date: 2019-02-01 16:07:58
Message-ID: 20190201160800.7334-2-matwey.kornilov@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Use shorter variable name instead of repeating in->scankeys[i] in
spg_quad_leaf_consistent() and spg_quad_inner_consistent().

Signed-off-by: Matwey V. Kornilov <matwey(dot)kornilov(at)gmail(dot)com>
---
src/backend/access/spgist/spgquadtreeproc.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/backend/access/spgist/spgquadtreeproc.c b/src/backend/access/spgist/spgquadtreeproc.c
index e50108e1ca..f2e980b758 100644
--- a/src/backend/access/spgist/spgquadtreeproc.c
+++ b/src/backend/access/spgist/spgquadtreeproc.c
@@ -300,10 +300,11 @@ spg_quad_inner_consistent(PG_FUNCTION_ARGS)

for (i = 0; i < in->nkeys; i++)
{
- Point *query = DatumGetPointP(in->scankeys[i].sk_argument);
+ const ScanKey sk = in->scankeys + i;
+ Point *query = DatumGetPointP(sk->sk_argument);
BOX *boxQuery;

- switch (in->scankeys[i].sk_strategy)
+ switch (sk->sk_strategy)
{
case RTLeftStrategyNumber:
if (SPTEST(point_right, centroid, query))
@@ -331,7 +332,7 @@ spg_quad_inner_consistent(PG_FUNCTION_ARGS)
* cheat to the extent of assuming that DatumGetPointP won't
* do anything that would be bad for a pointer-to-box.
*/
- boxQuery = DatumGetBoxP(in->scankeys[i].sk_argument);
+ boxQuery = DatumGetBoxP(sk->sk_argument);

if (DatumGetBool(DirectFunctionCall2(box_contain_pt,
PointerGetDatum(boxQuery),
@@ -358,8 +359,7 @@ spg_quad_inner_consistent(PG_FUNCTION_ARGS)
}
break;
default:
- elog(ERROR, "unrecognized strategy number: %d",
- in->scankeys[i].sk_strategy);
+ elog(ERROR, "unrecognized strategy number: %d", sk->sk_strategy);
break;
}

@@ -421,9 +421,10 @@ spg_quad_leaf_consistent(PG_FUNCTION_ARGS)
res = true;
for (i = 0; i < in->nkeys; i++)
{
- Point *query = DatumGetPointP(in->scankeys[i].sk_argument);
+ const ScanKey sk = in->scankeys + i;
+ Point *query = DatumGetPointP(sk->sk_argument);

- switch (in->scankeys[i].sk_strategy)
+ switch (sk->sk_strategy)
{
case RTLeftStrategyNumber:
res = SPTEST(point_left, datum, query);
@@ -450,8 +451,7 @@ spg_quad_leaf_consistent(PG_FUNCTION_ARGS)
res = SPTEST(box_contain_pt, query, datum);
break;
default:
- elog(ERROR, "unrecognized strategy number: %d",
- in->scankeys[i].sk_strategy);
+ elog(ERROR, "unrecognized strategy number: %d", sk->sk_strategy);
break;
}

--
2.13.7

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Matwey V. Kornilov 2019-02-01 16:07:59 [PATCH 2/3] Introduce spg_quad_inner_consistent_box_helper() in spgquadtreeproc.c
Previous Message Matwey V. Kornilov 2019-02-01 16:07:57 [PATCH 0/3] Introduce spgist quadtree @<(point,circle) operator