[PATCH] Const'ify the arguments of ilist.c/ilist.h functions

From: Aleksander Alekseev <aleksander(at)timescale(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: [PATCH] Const'ify the arguments of ilist.c/ilist.h functions
Date: 2022-11-07 09:03:23
Message-ID: CAJ7c6TM2=08mNKD9aJg8vEY9hd+G4L7+Nvh30UiNT3kShgRgNg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

During the [1] discussion it was suggested to constify the arguments
of ilist.c/ilist.h functions. Bharath (cc'ed) pointed out that it's
better to start a new thread in order to attract more hackers that may
be interested in this change, so I started one.

The patch is attached. Here are the reasons why we may want to do this:

"""
Const qualifiers ensure that we don't do something stupid in the function
implementation. Additionally they clarify the interface. As an example:

void
slist_delete(slist_head *head, const slist_node *node)

Here one can instantly tell that node->next is not going to be set to NULL.
Finally, const qualifiers potentially allow the compiler to do more
optimizations. This being said no benchmarking was done for this patch.
"""

Additionally Bharath pointed out that there are other pieces of code
that we may want to change in a similar fashion,
proclist.h/proclist_types.h as one example. I didn't do this yet
because I would like to know the community opinion first on whether we
should do this at all.

Thoughts?

[1]: https://www.postgresql.org/message-id/flat/CAApHDvrtVxr+FXEX0VbViCFKDGxA3tWDgw9oFewNXCJMmwLjLg(at)mail(dot)gmail(dot)com

--
Best regards,
Aleksander Alekseev

Attachment Content-Type Size
v1-0001-Constify-the-arguments-of-ilist.c-h-functions.patch application/octet-stream 10.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhang Mingli 2022-11-07 09:04:18 Re: [patch] Adding an assertion to report too long hash table name
Previous Message Karina Litskevich 2022-11-07 08:55:32 Re: Error for WITH options on partitioned tables