[PATCH] dynahash.c refactoring

Started by Aleksander Alekseev25 days ago4 messageshackers
Jump to latest
#1Aleksander Alekseev
aleksander@tigerdata.com

Hi,

0001: hash_freeze() has not been used since 5dfc198146 (Oct 2016). I
suggest removing it.

0002: hash_destroy() is the only caller of hash_stats(). I suggest
making the function static and place it under `#ifdef
HASH_STATISTICS`.

Thoughts?

--
Best regards,
Aleksander Alekseev

Attachments:

t254441_1
v1-0002-Make-hash_stats-static.patchtext/x-patch; charset=US-ASCII; name=v1-0002-Make-hash_stats-static.patchDownload+10-7
v1-0001-Remove-hash_freeze.patchtext/x-patch; charset=US-ASCII; name=v1-0001-Remove-hash_freeze.patchDownload+5-52
#2Peter Eisentraut
peter@eisentraut.org
In reply to: Aleksander Alekseev (#1)
Re: [PATCH] dynahash.c refactoring

On 29.10.26 12:03, Aleksander Alekseev wrote:

0001: hash_freeze() has not been used since 5dfc198146 (Oct 2016). I
suggest removing it.

This seems alright. If someone needs it, we can put it back.

0002: hash_destroy() is the only caller of hash_stats(). I suggest
making the function static and place it under `#ifdef
HASH_STATISTICS`.

I don't think this is an improvement. In general, I would like to keep
the amount of code covered by #ifdef's as small as possible. That way,
we reduce the chances that some code rots because it is not compiled by
default. We could make the function static, but I would avoid the
additional #ifdef's.

#3Aleksander Alekseev
aleksander@tigerdata.com
In reply to: Peter Eisentraut (#2)
Re: [PATCH] dynahash.c refactoring

Hi Peter,

0001: hash_freeze() has not been used since 5dfc198146 (Oct 2016). I
suggest removing it.

This seems alright. If someone needs it, we can put it back.

0002: hash_destroy() is the only caller of hash_stats(). I suggest
making the function static and place it under `#ifdef
HASH_STATISTICS`.

I don't think this is an improvement. In general, I would like to keep
the amount of code covered by #ifdef's as small as possible. That way,
we reduce the chances that some code rots because it is not compiled by
default. We could make the function static, but I would avoid the
additional #ifdef's.

Thanks for the feedback. Here are the corrected patches.

--
Best regards,
Aleksander Alekseev

Attachments:

t254441_3
v2-0001-Remove-hash_freeze.patchtext/x-patch; charset=US-ASCII; name=v2-0001-Remove-hash_freeze.patchDownload+5-52
v2-0002-Make-hash_stats-static.patchtext/x-patch; charset=US-ASCII; name=v2-0002-Make-hash_stats-static.patchDownload+2-3
#4Peter Eisentraut
peter@eisentraut.org
In reply to: Aleksander Alekseev (#3)
Re: [PATCH] dynahash.c refactoring

On 03.11.26 11:19, Aleksander Alekseev wrote:

Hi Peter,

0001: hash_freeze() has not been used since 5dfc198146 (Oct 2016). I
suggest removing it.

This seems alright. If someone needs it, we can put it back.

0002: hash_destroy() is the only caller of hash_stats(). I suggest
making the function static and place it under `#ifdef
HASH_STATISTICS`.

I don't think this is an improvement. In general, I would like to keep
the amount of code covered by #ifdef's as small as possible. That way,
we reduce the chances that some code rots because it is not compiled by
default. We could make the function static, but I would avoid the
additional #ifdef's.

Thanks for the feedback. Here are the corrected patches.

I have committed the patch to remove hash_freeze().

About hash_stats(), the header comment in dynahash.c still mentioned
hash_stats() as a public interface. That would have to be adjusted. On
further thought, let's just leave that alone. There is nothing wrong
with having this as an external interface, for example to debug the hash
table usage of some algorithm.