aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/help_config.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-10-14 12:26:39 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-10-14 12:26:39 -0400
commit3057465acfbea2f3dd7a914a1478064022c6eecd (patch)
tree63de056985ef04bedf14c1baab0c53ebb3f7c326 /src/backend/utils/misc/help_config.c
parent407b50f2d421bca5b134a0033176ea8f8c68dc6b (diff)
downloadpostgresql-3057465acfbea2f3dd7a914a1478064022c6eecd.tar.gz
postgresql-3057465acfbea2f3dd7a914a1478064022c6eecd.zip
Replace the sorted array of GUC variables with a hash table.
This gets rid of bsearch() in favor of hashed lookup. The main advantage is that it becomes far cheaper to add new GUCs, since we needn't re-sort the pointer array. Adding N new GUCs had been O(N^2 log N), but now it's closer to O(N). We need to sort only in SHOW ALL and equivalent functions, which are hopefully not performance-critical to anybody. Also, merge GetNumConfigOptions() into get_guc_variables(), because in a world where the set of GUCs isn't fairly static you really want to consider those two results as tied together not independent. Discussion: https://postgr.es/m/2982579.1662416866@sss.pgh.pa.us
Diffstat (limited to 'src/backend/utils/misc/help_config.c')
-rw-r--r--src/backend/utils/misc/help_config.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/backend/utils/misc/help_config.c b/src/backend/utils/misc/help_config.c
index 61c83f35901..59d2e36548e 100644
--- a/src/backend/utils/misc/help_config.c
+++ b/src/backend/utils/misc/help_config.c
@@ -49,11 +49,10 @@ GucInfoMain(void)
int numOpts,
i;
- /* Initialize the guc_variables[] array */
+ /* Initialize the GUC hash table */
build_guc_variables();
- guc_vars = get_guc_variables();
- numOpts = GetNumConfigOptions();
+ guc_vars = get_guc_variables(&numOpts);
for (i = 0; i < numOpts; i++)
{