@@ -941,25 +941,22 @@ hash_search_with_hash_value(HTAB *hashp,
941941 case HASH_REMOVE :
942942 if (currBucket != NULL )
943943 {
944- /* use volatile pointer to prevent code rearrangement */
945- volatile HASHHDR * hctlv = hctl ;
946-
947944 /* if partitioned, must lock to touch nentries and freeList */
948- if (IS_PARTITIONED (hctlv ))
949- SpinLockAcquire (& hctlv -> mutex );
945+ if (IS_PARTITIONED (hctl ))
946+ SpinLockAcquire (& hctl -> mutex );
950947
951- Assert (hctlv -> nentries > 0 );
952- hctlv -> nentries -- ;
948+ Assert (hctl -> nentries > 0 );
949+ hctl -> nentries -- ;
953950
954951 /* remove record from hash bucket's chain. */
955952 * prevBucketPtr = currBucket -> link ;
956953
957954 /* add the record to the freelist for this table. */
958- currBucket -> link = hctlv -> freeList ;
959- hctlv -> freeList = currBucket ;
955+ currBucket -> link = hctl -> freeList ;
956+ hctl -> freeList = currBucket ;
960957
961- if (IS_PARTITIONED (hctlv ))
962- SpinLockRelease (& hctlv -> mutex );
958+ if (IS_PARTITIONED (hctl ))
959+ SpinLockRelease (& hctl -> mutex );
963960
964961 /*
965962 * better hope the caller is synchronizing access to this
@@ -1180,38 +1177,37 @@ hash_update_hash_key(HTAB *hashp,
11801177static HASHBUCKET
11811178get_hash_entry (HTAB * hashp )
11821179{
1183- /* use volatile pointer to prevent code rearrangement */
1184- volatile HASHHDR * hctlv = hashp -> hctl ;
1180+ HASHHDR * hctl = hashp -> hctl ;
11851181 HASHBUCKET newElement ;
11861182
11871183 for (;;)
11881184 {
11891185 /* if partitioned, must lock to touch nentries and freeList */
1190- if (IS_PARTITIONED (hctlv ))
1191- SpinLockAcquire (& hctlv -> mutex );
1186+ if (IS_PARTITIONED (hctl ))
1187+ SpinLockAcquire (& hctl -> mutex );
11921188
11931189 /* try to get an entry from the freelist */
1194- newElement = hctlv -> freeList ;
1190+ newElement = hctl -> freeList ;
11951191 if (newElement != NULL )
11961192 break ;
11971193
11981194 /* no free elements. allocate another chunk of buckets */
1199- if (IS_PARTITIONED (hctlv ))
1200- SpinLockRelease (& hctlv -> mutex );
1195+ if (IS_PARTITIONED (hctl ))
1196+ SpinLockRelease (& hctl -> mutex );
12011197
1202- if (!element_alloc (hashp , hctlv -> nelem_alloc ))
1198+ if (!element_alloc (hashp , hctl -> nelem_alloc ))
12031199 {
12041200 /* out of memory */
12051201 return NULL ;
12061202 }
12071203 }
12081204
12091205 /* remove entry from freelist, bump nentries */
1210- hctlv -> freeList = newElement -> link ;
1211- hctlv -> nentries ++ ;
1206+ hctl -> freeList = newElement -> link ;
1207+ hctl -> nentries ++ ;
12121208
1213- if (IS_PARTITIONED (hctlv ))
1214- SpinLockRelease (& hctlv -> mutex );
1209+ if (IS_PARTITIONED (hctl ))
1210+ SpinLockRelease (& hctl -> mutex );
12151211
12161212 return newElement ;
12171213}
@@ -1536,8 +1532,7 @@ seg_alloc(HTAB *hashp)
15361532static bool
15371533element_alloc (HTAB * hashp , int nelem )
15381534{
1539- /* use volatile pointer to prevent code rearrangement */
1540- volatile HASHHDR * hctlv = hashp -> hctl ;
1535+ HASHHDR * hctl = hashp -> hctl ;
15411536 Size elementSize ;
15421537 HASHELEMENT * firstElement ;
15431538 HASHELEMENT * tmpElement ;
@@ -1548,7 +1543,7 @@ element_alloc(HTAB *hashp, int nelem)
15481543 return false;
15491544
15501545 /* Each element has a HASHELEMENT header plus user data. */
1551- elementSize = MAXALIGN (sizeof (HASHELEMENT )) + MAXALIGN (hctlv -> entrysize );
1546+ elementSize = MAXALIGN (sizeof (HASHELEMENT )) + MAXALIGN (hctl -> entrysize );
15521547
15531548 CurrentDynaHashCxt = hashp -> hcxt ;
15541549 firstElement = (HASHELEMENT * ) hashp -> alloc (nelem * elementSize );
@@ -1567,15 +1562,15 @@ element_alloc(HTAB *hashp, int nelem)
15671562 }
15681563
15691564 /* if partitioned, must lock to touch freeList */
1570- if (IS_PARTITIONED (hctlv ))
1571- SpinLockAcquire (& hctlv -> mutex );
1565+ if (IS_PARTITIONED (hctl ))
1566+ SpinLockAcquire (& hctl -> mutex );
15721567
15731568 /* freelist could be nonempty if two backends did this concurrently */
1574- firstElement -> link = hctlv -> freeList ;
1575- hctlv -> freeList = prevElement ;
1569+ firstElement -> link = hctl -> freeList ;
1570+ hctl -> freeList = prevElement ;
15761571
1577- if (IS_PARTITIONED (hctlv ))
1578- SpinLockRelease (& hctlv -> mutex );
1572+ if (IS_PARTITIONED (hctl ))
1573+ SpinLockRelease (& hctl -> mutex );
15791574
15801575 return true;
15811576}
0 commit comments