Commit b897b3aa authored by Peter Geoghegan's avatar Peter Geoghegan

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 already
code 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 avoid
it 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 rightmost
leaf page cache optimization, which was added by commit 2b272734.
parent 9b8aa092
......@@ -1180,13 +1180,8 @@ _bt_insertonpg(Relation rel,
Buffer metabuf = InvalidBuffer;
Page metapg = NULL;
BTMetaPageData *metad = NULL;
OffsetNumber itup_off;
BlockNumber itup_blkno;
BlockNumber cachedBlock = InvalidBlockNumber;
itup_off = newitemoff;
itup_blkno = BufferGetBlockNumber(buf);
/*
* If we are doing this insert because we split a page that was the
* only one on its tree level, but was not the root, it may have been
......@@ -1218,7 +1213,7 @@ _bt_insertonpg(Relation rel,
if (!_bt_pgaddtup(page, itemsz, itup, newitemoff))
elog(PANIC, "failed to add new item to block %u in index \"%s\"",
itup_blkno, RelationGetRelationName(rel));
BufferGetBlockNumber(buf), RelationGetRelationName(rel));
MarkBufferDirty(buf);
......@@ -1227,7 +1222,7 @@ _bt_insertonpg(Relation rel,
/* upgrade meta-page if needed */
if (metad->btm_version < BTREE_NOVAC_VERSION)
_bt_upgrademetapage(metapg);
metad->btm_fastroot = itup_blkno;
metad->btm_fastroot = BufferGetBlockNumber(buf);
metad->btm_fastlevel = lpageop->btpo.level;
MarkBufferDirty(metabuf);
}
......@@ -1260,7 +1255,7 @@ _bt_insertonpg(Relation rel,
uint8 xlinfo;
XLogRecPtr recptr;
xlrec.offnum = itup_off;
xlrec.offnum = newitemoff;
XLogBeginInsert();
XLogRegisterData((char *) &xlrec, SizeOfBtreeInsert);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment