Re: Remove unneccessary memory initialization in planner.c

From: Aleksander Alekseev <aleksander(at)tigerdata(dot)com>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Subject: Re: Remove unneccessary memory initialization in planner.c
Date: 2025-12-08 12:17:25
Message-ID: CAJ7c6TM8g=z-v_qYFN5FWzWPUph=gTRvZWWyiDADN_7g5tZ6CQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Chao,

> "gd" is allocated by palloc0, so all members have been zero initialized, thus explicitly assigning NULL to the 4 members is unnecessary. I don't think that has much runtime impact, but from a readability perspective, a potential question is that, "gd" has more fields, why only set 0 to these 4 members redundantly?
>
> To avoid the potential confusion, I think we'd better delete these initializations.

Good find. I agree that this code is redundant. Or alternatively we
should do palloc() and assign all the initial values explicitly.

--
Best regards,
Aleksander Alekseev

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2025-12-08 12:26:19 Re: SQL Property Graph Queries (SQL/PGQ)
Previous Message Amit Kapila 2025-12-08 12:14:19 Re: Skipping schema changes in publication