mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Inline TransactionIdFollows/Precedes[OrEquals]()
These functions appeared prominently in a profile of a patch that sets the visibility map on-access. Inline them to remove call overhead and make them cheaper to use in hot paths. Author: Melanie Plageman <melanieplageman@gmail.com> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/2wk7jo4m4qwh5sn33pfgerdjfujebbccsmmlownybddbh6nawl%40mdyyqpqzxjek
This commit is contained in:
@@ -273,70 +273,6 @@ TransactionIdAbortTree(TransactionId xid, int nxids, TransactionId *xids)
|
||||
TRANSACTION_STATUS_ABORTED, InvalidXLogRecPtr);
|
||||
}
|
||||
|
||||
/*
|
||||
* TransactionIdPrecedes --- is id1 logically < id2?
|
||||
*/
|
||||
bool
|
||||
TransactionIdPrecedes(TransactionId id1, TransactionId id2)
|
||||
{
|
||||
/*
|
||||
* If either ID is a permanent XID then we can just do unsigned
|
||||
* comparison. If both are normal, do a modulo-2^32 comparison.
|
||||
*/
|
||||
int32 diff;
|
||||
|
||||
if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2))
|
||||
return (id1 < id2);
|
||||
|
||||
diff = (int32) (id1 - id2);
|
||||
return (diff < 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* TransactionIdPrecedesOrEquals --- is id1 logically <= id2?
|
||||
*/
|
||||
bool
|
||||
TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
|
||||
{
|
||||
int32 diff;
|
||||
|
||||
if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2))
|
||||
return (id1 <= id2);
|
||||
|
||||
diff = (int32) (id1 - id2);
|
||||
return (diff <= 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* TransactionIdFollows --- is id1 logically > id2?
|
||||
*/
|
||||
bool
|
||||
TransactionIdFollows(TransactionId id1, TransactionId id2)
|
||||
{
|
||||
int32 diff;
|
||||
|
||||
if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2))
|
||||
return (id1 > id2);
|
||||
|
||||
diff = (int32) (id1 - id2);
|
||||
return (diff > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* TransactionIdFollowsOrEquals --- is id1 logically >= id2?
|
||||
*/
|
||||
bool
|
||||
TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2)
|
||||
{
|
||||
int32 diff;
|
||||
|
||||
if (!TransactionIdIsNormal(id1) || !TransactionIdIsNormal(id2))
|
||||
return (id1 >= id2);
|
||||
|
||||
diff = (int32) (id1 - id2);
|
||||
return (diff >= 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* TransactionIdLatest --- get latest XID among a main xact and its children
|
||||
|
||||
Reference in New Issue
Block a user