[PATCH] Const'ify the arguments of ilist.c/ilist.h functions - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject [PATCH] Const'ify the arguments of ilist.c/ilist.h functions
Date
Msg-id CAJ7c6TM2=08mNKD9aJg8vEY9hd+G4L7+Nvh30UiNT3kShgRgNg@mail.gmail.com
Whole thread Raw
Responses Re: [PATCH] Const'ify the arguments of ilist.c/ilist.h functions
List 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@mail.gmail.com

-- 
Best regards,
Aleksander Alekseev

Attachment

pgsql-hackers by date:

Previous
From: Karina Litskevich
Date:
Subject: Re: Error for WITH options on partitioned tables
Next
From: Zhang Mingli
Date:
Subject: Re: [patch] Adding an assertion to report too long hash table name