Re: nbtree: reduce code redundancy by using _bt_getmeta() in _bt_gettrueroot()

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: nbtree: reduce code redundancy by using _bt_getmeta() in _bt_gettrueroot()
Date: 2026-07-07 21:32:21
Message-ID: 752d1c03-43eb-4f41-b2e6-8fbadb03113f@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 16/01/2026 10:09, Neil Chen wrote:
> Hi Chao,
>
> On Thu, Jan 15, 2026 at 4:11 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com
> <mailto:li(dot)evan(dot)chao(at)gmail(dot)com>> wrote:
>
>
> I noticed this while reviewing [1]. _bt_gettrueroot() performs the
> same metapage checks as _bt_getmeta(), so using _bt_getmeta() here
> removes the duplicated code.
>
>
> It looks good to me. These two code snippets are exactly identical,
> so removing the redundant code is reasonable.
>
> As can be seen from the contextual comments, this is not a performance-
> critical path either,
> so we don’t need to worry about the performance overhead caused by
> function calls.
>
> I also checked the changes made in commit dd299df, which essentially
> does the same thing for the function _bt_getrootheight.

Ok, committed.

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2026-07-07 21:44:46 Re: Proposal: new file format for hba/ident/hosts configuration?
Previous Message Andrew Dunstan 2026-07-07 21:21:18 Re: Proposal: new file format for hba/ident/hosts configuration?