pgsql: Use branchless comparisons in btint4cmp and btint8cmp, for speed

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use branchless comparisons in btint4cmp and btint8cmp, for speed
Date: 2026-11-05 11:58:11
Message-ID: E1xOw6e-00000000IwW-0fv7@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Use branchless comparisons in btint4cmp and btint8cmp, for speed

The comment on pg_cmp_*() points out that the old form can produce
better code if the comparison is inlined, but that's not a concern
here because btint4cmp() and btint8cmp() are invoked through the
function manager and won't be inlined.

Author: David Geier <geidav(dot)pg(at)gmail(dot)com>
Reviewed-by: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Reviewed-by: Kirill Reshke <reshkekirill(at)gmail(dot)com>
Reviewed-by: Japin Li <japinli(at)hotmail(dot)com>
Discussion: https://www.postgresql.org/message-id/5d366878-2007-4d31-861e-19294b7a583b@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/41467b1d88303fbaea4ddd20c21ac4b8ce6b92d7

Modified Files
--------------
src/backend/access/nbtree/nbtcompare.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-11-05 13:16:14 pgsql: oauth: Recheck oauth_validator_libraries during authentication
Previous Message Fujii Masao 2026-11-05 09:09:02 pgsql: Fix stale visibility maps in incremental backups after heap trun