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

Commitb897b3a

Browse files
nbtree: Remove useless local variables.
Copying block and offset numbers to local variables in _bt_insertonpg()made the code less readable. Remove the variables. There is alreadycode that conditionally calls BufferGetBlockNumber() in the same block,so consistently do it that way instead.Calling BufferGetBlockNumber() is very cheap, but we might as well avoidit when it isn't truly necessary. It isn't truly necessary for_bt_insertonpg() to call BufferGetBlockNumber() in almost all cases.Spotted while working on a patch that refactors the fastpath rightmostleaf page cache optimization, which was added by commit2b27273.
1 parent9b8aa09 commitb897b3a

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

‎src/backend/access/nbtree/nbtinsert.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,13 +1180,8 @@ _bt_insertonpg(Relation rel,
11801180
Buffermetabuf=InvalidBuffer;
11811181
Pagemetapg=NULL;
11821182
BTMetaPageData*metad=NULL;
1183-
OffsetNumberitup_off;
1184-
BlockNumberitup_blkno;
11851183
BlockNumbercachedBlock=InvalidBlockNumber;
11861184

1187-
itup_off=newitemoff;
1188-
itup_blkno=BufferGetBlockNumber(buf);
1189-
11901185
/*
11911186
* If we are doing this insert because we split a page that was the
11921187
* only one on its tree level, but was not the root, it may have been
@@ -1218,7 +1213,7 @@ _bt_insertonpg(Relation rel,
12181213

12191214
if (!_bt_pgaddtup(page,itemsz,itup,newitemoff))
12201215
elog(PANIC,"failed to add new item to block %u in index \"%s\"",
1221-
itup_blkno,RelationGetRelationName(rel));
1216+
BufferGetBlockNumber(buf),RelationGetRelationName(rel));
12221217

12231218
MarkBufferDirty(buf);
12241219

@@ -1227,7 +1222,7 @@ _bt_insertonpg(Relation rel,
12271222
/* upgrade meta-page if needed */
12281223
if (metad->btm_version<BTREE_NOVAC_VERSION)
12291224
_bt_upgrademetapage(metapg);
1230-
metad->btm_fastroot=itup_blkno;
1225+
metad->btm_fastroot=BufferGetBlockNumber(buf);
12311226
metad->btm_fastlevel=lpageop->btpo.level;
12321227
MarkBufferDirty(metabuf);
12331228
}
@@ -1260,7 +1255,7 @@ _bt_insertonpg(Relation rel,
12601255
uint8xlinfo;
12611256
XLogRecPtrrecptr;
12621257

1263-
xlrec.offnum=itup_off;
1258+
xlrec.offnum=newitemoff;
12641259

12651260
XLogBeginInsert();
12661261
XLogRegisterData((char*)&xlrec,SizeOfBtreeInsert);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp