1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Remove unnecessary "head" arguments from some dlist/slist functions.

dlist_delete, dlist_insert_after, dlist_insert_before, slist_insert_after
do not need access to the list header, and indeed insisting on that negates
one of the main advantages of a doubly-linked list.

In consequence, revert addition of "cache_bucket" field to CatCTup.
This commit is contained in:
Tom Lane
2012-10-18 19:04:20 -04:00
parent 8f8d746478
commit dc5aeca168
5 changed files with 27 additions and 48 deletions

View File

@ -580,7 +580,6 @@ AutoVacLauncherMain(int argc, char *argv[])
struct timeval nap;
TimestampTz current_time = 0;
bool can_launch;
avl_dbase *avdb;
int rc;
/*
@ -725,7 +724,8 @@ AutoVacLauncherMain(int argc, char *argv[])
worker->wi_tableoid = InvalidOid;
worker->wi_proc = NULL;
worker->wi_launchtime = 0;
dlist_push_head(&AutoVacuumShmem->av_freeWorkers, &worker->wi_links);
dlist_push_head(&AutoVacuumShmem->av_freeWorkers,
&worker->wi_links);
AutoVacuumShmem->av_startingWorker = NULL;
elog(WARNING, "worker took too long to start; canceled");
}
@ -760,6 +760,8 @@ AutoVacLauncherMain(int argc, char *argv[])
* distant adl_next_worker first, we obtain our database from the
* tail of the list.
*/
avl_dbase *avdb;
avdb = dlist_tail_element(avl_dbase, adl_node, &DatabaseList);
/*
@ -790,8 +792,6 @@ AutoVacLauncherMain(int argc, char *argv[])
static void
launcher_determine_sleep(bool canlaunch, bool recursing, struct timeval * nap)
{
avl_dbase *avdb;
/*
* We sleep until the next scheduled vacuum. We trust that when the
* database list was built, care was taken so that no entries have times
@ -807,6 +807,7 @@ launcher_determine_sleep(bool canlaunch, bool recursing, struct timeval * nap)
{
TimestampTz current_time = GetCurrentTimestamp();
TimestampTz next_wakeup;
avl_dbase *avdb;
long secs;
int usecs;
@ -1677,7 +1678,7 @@ FreeWorkerInfo(int code, Datum arg)
*/
AutovacuumLauncherPid = AutoVacuumShmem->av_launcherpid;
dlist_delete(&AutoVacuumShmem->av_runningWorkers, &MyWorkerInfo->wi_links);
dlist_delete(&MyWorkerInfo->wi_links);
MyWorkerInfo->wi_dboid = InvalidOid;
MyWorkerInfo->wi_tableoid = InvalidOid;
MyWorkerInfo->wi_proc = NULL;
@ -1685,7 +1686,8 @@ FreeWorkerInfo(int code, Datum arg)
MyWorkerInfo->wi_cost_delay = 0;
MyWorkerInfo->wi_cost_limit = 0;
MyWorkerInfo->wi_cost_limit_base = 0;
dlist_push_head(&AutoVacuumShmem->av_freeWorkers, &MyWorkerInfo->wi_links);
dlist_push_head(&AutoVacuumShmem->av_freeWorkers,
&MyWorkerInfo->wi_links);
/* not mine anymore */
MyWorkerInfo = NULL;
@ -2863,7 +2865,8 @@ AutoVacuumShmemInit(void)
/* initialize the WorkerInfo free list */
for (i = 0; i < autovacuum_max_workers; i++)
dlist_push_head(&AutoVacuumShmem->av_freeWorkers, &worker[i].wi_links);
dlist_push_head(&AutoVacuumShmem->av_freeWorkers,
&worker[i].wi_links);
}
else
Assert(found);

View File

@ -2696,7 +2696,7 @@ CleanupBackend(int pid,
ShmemBackendArrayRemove(bp);
#endif
}
dlist_delete(&BackendList, iter.cur);
dlist_delete(iter.cur);
free(bp);
break;
}
@ -2744,7 +2744,7 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
ShmemBackendArrayRemove(bp);
#endif
}
dlist_delete(&BackendList, iter.cur);
dlist_delete(iter.cur);
free(bp);
/* Keep looping so we can signal remaining backends */
}

View File

@ -370,7 +370,7 @@ CatCacheRemoveCTup(CatCache *cache, CatCTup *ct)
return; /* nothing left to do */
}
dlist_delete(ct->cache_bucket, &ct->cache_elem);
dlist_delete(&ct->cache_elem);
/* free associated tuple data */
if (ct->tuple.t_data != NULL)
@ -413,7 +413,7 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl)
}
/* delink from linked list */
dlist_delete(&cache->cc_lists, &cl->cache_elem);
dlist_delete(&cl->cache_elem);
/* free associated tuple data */
if (cl->tuple.t_data != NULL)
@ -1664,15 +1664,13 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp,
*/
ct->ct_magic = CT_MAGIC;
ct->my_cache = cache;
ct->cache_bucket = &cache->cc_bucket[hashIndex];
ct->c_list = NULL;
ct->refcount = 0; /* for the moment */
ct->dead = false;
ct->negative = negative;
ct->hash_value = hashValue;
dlist_push_head(ct->cache_bucket, &ct->cache_elem);
dlist_push_head(&cache->cc_bucket[hashIndex], &ct->cache_elem);
cache->cc_ntup++;
CacheHdr->ch_ntup++;