1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Inline the easy cases in MakeExpandedObjectReadOnly().

This attempts to buy back some of whatever performance we lost from fixing
bug #14174 by inlining the initial checks in MakeExpandedObjectReadOnly()
into the callers.  We can do that in a macro without creating multiple-
evaluation hazards, so it's pretty much free notationally; and the amount
of code added to callers should be minimal as well.  (Testing a value can't
take many more instructions than passing it to a subroutine.)

Might as well inline DatumIsReadWriteExpandedObject() while we're at it.

This is an ABI break for callers, so it doesn't seem safe to put into 9.5,
but I see no reason not to do it in HEAD.
This commit is contained in:
Tom Lane
2016-06-03 18:34:05 -04:00
parent 9eaf5be506
commit d50183c578
2 changed files with 14 additions and 24 deletions

View File

@ -84,36 +84,18 @@ EOH_flatten_into(ExpandedObjectHeader *eohptr,
(*eohptr->eoh_methods->flatten_into) (eohptr, result, allocated_size);
}
/*
* Does the Datum represent a writable expanded object?
*/
bool
DatumIsReadWriteExpandedObject(Datum d, bool isnull, int16 typlen)
{
/* Reject if it's NULL or not a varlena type */
if (isnull || typlen != -1)
return false;
/* Reject if not a read-write expanded-object pointer */
if (!VARATT_IS_EXTERNAL_EXPANDED_RW(DatumGetPointer(d)))
return false;
return true;
}
/*
* If the Datum represents a R/W expanded object, change it to R/O.
* Otherwise return the original Datum.
*
* Caller must ensure that the datum is a non-null varlena value. Typically
* this is invoked via MakeExpandedObjectReadOnly(), which checks that.
*/
Datum
MakeExpandedObjectReadOnly(Datum d, bool isnull, int16 typlen)
MakeExpandedObjectReadOnlyInternal(Datum d)
{
ExpandedObjectHeader *eohptr;
/* Nothing to do if it's NULL or not a varlena type */
if (isnull || typlen != -1)
return d;
/* Nothing to do if not a read-write expanded-object pointer */
if (!VARATT_IS_EXTERNAL_EXPANDED_RW(DatumGetPointer(d)))
return d;