| From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
|---|---|
| To: | Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Remove unneccessary memory initialization in planner.c |
| Date: | 2025-12-08 11:10:58 |
| Message-ID: | CAEoWx2k26k7KdnraJFiRumMXxLea+TqExsBUnTPP4B6XZMkC6Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Hackers,
In this code piece:
```
static grouping_sets_data *
preprocess_grouping_sets(PlannerInfo *root)
{
...
grouping_sets_data *gd = palloc0(sizeof(grouping_sets_data));
...
gd->any_hashable = false;
gd->unhashable_refs = NULL;
gd->unsortable_refs = NULL;
gd->unsortable_sets = NIL;
...
```
"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.
Begards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Remove-unneccessary-memory-initialization-in-plan.patch | application/octet-stream | 934 bytes |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2025-12-08 11:14:28 | Re: get rid of Pointer type, mostly |
| Previous Message | Chao Li | 2025-12-08 10:53:15 | Re: get rid of Pointer type, mostly |