Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f79cb7

Browse files
committed
slru.c: Reduce scope of variables in 'for' blocks
Pretty boring.
1 parent6e951bf commit5f79cb7

File tree

1 file changed

+11
-22
lines changed
  • src/backend/access/transam

1 file changed

+11
-22
lines changed

‎src/backend/access/transam/slru.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
228228
/* Initialize locks and shared memory area */
229229
char*ptr;
230230
Sizeoffset;
231-
intslotno;
232231

233232
Assert(!found);
234233

@@ -268,7 +267,7 @@ SimpleLruInit(SlruCtl ctl, const char *name, int nslots, int nlsns,
268267
}
269268

270269
ptr+=BUFFERALIGN(offset);
271-
for (slotno=0;slotno<nslots;slotno++)
270+
for (intslotno=0;slotno<nslots;slotno++)
272271
{
273272
LWLockInitialize(&shared->buffer_locks[slotno].lock,
274273
tranche_id);
@@ -530,13 +529,12 @@ int
530529
SimpleLruReadPage_ReadOnly(SlruCtlctl,int64pageno,TransactionIdxid)
531530
{
532531
SlruSharedshared=ctl->shared;
533-
intslotno;
534532

535533
/* Try to find the page while holding only shared lock */
536534
LWLockAcquire(shared->ControlLock,LW_SHARED);
537535

538536
/* See if page is already in a buffer */
539-
for (slotno=0;slotno<shared->num_slots;slotno++)
537+
for (intslotno=0;slotno<shared->num_slots;slotno++)
540538
{
541539
if (shared->page_number[slotno]==pageno&&
542540
shared->page_status[slotno]!=SLRU_PAGE_EMPTY&&
@@ -612,9 +610,7 @@ SlruInternalWritePage(SlruCtl ctl, int slotno, SlruWriteAll fdata)
612610
/* If we failed, and we're in a flush, better close the files */
613611
if (!ok&&fdata)
614612
{
615-
inti;
616-
617-
for (i=0;i<fdata->num_files;i++)
613+
for (inti=0;i<fdata->num_files;i++)
618614
CloseTransientFile(fdata->fd[i]);
619615
}
620616

@@ -815,12 +811,11 @@ SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
815811
* transaction-commit path).
816812
*/
817813
XLogRecPtrmax_lsn;
818-
intlsnindex,
819-
lsnoff;
814+
intlsnindex;
820815

821816
lsnindex=slotno*shared->lsn_groups_per_page;
822817
max_lsn=shared->group_lsn[lsnindex++];
823-
for (lsnoff=1;lsnoff<shared->lsn_groups_per_page;lsnoff++)
818+
for (intlsnoff=1;lsnoff<shared->lsn_groups_per_page;lsnoff++)
824819
{
825820
XLogRecPtrthis_lsn=shared->group_lsn[lsnindex++];
826821

@@ -847,9 +842,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int64 pageno, int slotno, SlruWriteAll fdata)
847842
*/
848843
if (fdata)
849844
{
850-
inti;
851-
852-
for (i=0;i<fdata->num_files;i++)
845+
for (inti=0;i<fdata->num_files;i++)
853846
{
854847
if (fdata->segno[i]==segno)
855848
{
@@ -1055,7 +1048,6 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
10551048
/* Outer loop handles restart after I/O */
10561049
for (;;)
10571050
{
1058-
intslotno;
10591051
intcur_count;
10601052
intbestvalidslot=0;/* keep compiler quiet */
10611053
intbest_valid_delta=-1;
@@ -1065,7 +1057,7 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
10651057
int64best_invalid_page_number=0;/* keep compiler quiet */
10661058

10671059
/* See if page already has a buffer assigned */
1068-
for (slotno=0;slotno<shared->num_slots;slotno++)
1060+
for (intslotno=0;slotno<shared->num_slots;slotno++)
10691061
{
10701062
if (shared->page_number[slotno]==pageno&&
10711063
shared->page_status[slotno]!=SLRU_PAGE_EMPTY)
@@ -1100,7 +1092,7 @@ SlruSelectLRUPage(SlruCtl ctl, int64 pageno)
11001092
* multiple pages with the same lru_count.
11011093
*/
11021094
cur_count= (shared->cur_lru_count)++;
1103-
for (slotno=0;slotno<shared->num_slots;slotno++)
1095+
for (intslotno=0;slotno<shared->num_slots;slotno++)
11041096
{
11051097
intthis_delta;
11061098
int64this_page_number;
@@ -1200,9 +1192,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
12001192
{
12011193
SlruSharedshared=ctl->shared;
12021194
SlruWriteAllDatafdata;
1203-
intslotno;
12041195
int64pageno=0;
1205-
inti;
12061196
boolok;
12071197

12081198
/* update the stats counter of flushes */
@@ -1215,7 +1205,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
12151205

12161206
LWLockAcquire(shared->ControlLock,LW_EXCLUSIVE);
12171207

1218-
for (slotno=0;slotno<shared->num_slots;slotno++)
1208+
for (intslotno=0;slotno<shared->num_slots;slotno++)
12191209
{
12201210
SlruInternalWritePage(ctl,slotno,&fdata);
12211211

@@ -1236,7 +1226,7 @@ SimpleLruWriteAll(SlruCtl ctl, bool allow_redirtied)
12361226
* Now close any files that were open
12371227
*/
12381228
ok= true;
1239-
for (i=0;i<fdata.num_files;i++)
1229+
for (inti=0;i<fdata.num_files;i++)
12401230
{
12411231
if (CloseTransientFile(fdata.fd[i])!=0)
12421232
{
@@ -1372,14 +1362,13 @@ void
13721362
SlruDeleteSegment(SlruCtlctl,int64segno)
13731363
{
13741364
SlruSharedshared=ctl->shared;
1375-
intslotno;
13761365
booldid_write;
13771366

13781367
/* Clean out any possibly existing references to the segment. */
13791368
LWLockAcquire(shared->ControlLock,LW_EXCLUSIVE);
13801369
restart:
13811370
did_write= false;
1382-
for (slotno=0;slotno<shared->num_slots;slotno++)
1371+
for (intslotno=0;slotno<shared->num_slots;slotno++)
13831372
{
13841373
intpagesegno=shared->page_number[slotno] /SLRU_PAGES_PER_SEGMENT;
13851374

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp