Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd50183c

Browse files
committed
Inline the easy cases in MakeExpandedObjectReadOnly().
This attempts to buy back some of whatever performance we lost from fixingbug #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 amountof code added to callers should be minimal as well. (Testing a value can'ttake 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.
1 parent9eaf5be commitd50183c

File tree

2 files changed

+14
-24
lines changed

2 files changed

+14
-24
lines changed

‎src/backend/utils/adt/expandeddatum.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,36 +84,18 @@ EOH_flatten_into(ExpandedObjectHeader *eohptr,
8484
(*eohptr->eoh_methods->flatten_into) (eohptr,result,allocated_size);
8585
}
8686

87-
/*
88-
* Does the Datum represent a writable expanded object?
89-
*/
90-
bool
91-
DatumIsReadWriteExpandedObject(Datumd,boolisnull,int16typlen)
92-
{
93-
/* Reject if it's NULL or not a varlena type */
94-
if (isnull||typlen!=-1)
95-
return false;
96-
97-
/* Reject if not a read-write expanded-object pointer */
98-
if (!VARATT_IS_EXTERNAL_EXPANDED_RW(DatumGetPointer(d)))
99-
return false;
100-
101-
return true;
102-
}
103-
10487
/*
10588
* If the Datum represents a R/W expanded object, change it to R/O.
10689
* Otherwise return the original Datum.
90+
*
91+
* Caller must ensure that the datum is a non-null varlena value. Typically
92+
* this is invoked via MakeExpandedObjectReadOnly(), which checks that.
10793
*/
10894
Datum
109-
MakeExpandedObjectReadOnly(Datumd,boolisnull,int16typlen)
95+
MakeExpandedObjectReadOnlyInternal(Datumd)
11096
{
11197
ExpandedObjectHeader*eohptr;
11298

113-
/* Nothing to do if it's NULL or not a varlena type */
114-
if (isnull||typlen!=-1)
115-
returnd;
116-
11799
/* Nothing to do if not a read-write expanded-object pointer */
118100
if (!VARATT_IS_EXTERNAL_EXPANDED_RW(DatumGetPointer(d)))
119101
returnd;

‎src/include/utils/expandeddatum.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,23 @@ struct ExpandedObjectHeader
136136
#defineEOHPGetRWDatum(eohptr)PointerGetDatum((eohptr)->eoh_rw_ptr)
137137
#defineEOHPGetRODatum(eohptr)PointerGetDatum((eohptr)->eoh_ro_ptr)
138138

139+
/* Does the Datum represent a writable expanded object? */
140+
#defineDatumIsReadWriteExpandedObject(d,isnull,typlen) \
141+
(((isnull) || (typlen) != -1) ? false : \
142+
VARATT_IS_EXTERNAL_EXPANDED_RW(DatumGetPointer(d)))
143+
144+
#defineMakeExpandedObjectReadOnly(d,isnull,typlen) \
145+
(((isnull) || (typlen) != -1) ? (d) : \
146+
MakeExpandedObjectReadOnlyInternal(d))
147+
139148
externExpandedObjectHeader*DatumGetEOHP(Datumd);
140149
externvoidEOH_init_header(ExpandedObjectHeader*eohptr,
141150
constExpandedObjectMethods*methods,
142151
MemoryContextobj_context);
143152
externSizeEOH_get_flat_size(ExpandedObjectHeader*eohptr);
144153
externvoidEOH_flatten_into(ExpandedObjectHeader*eohptr,
145154
void*result,Sizeallocated_size);
146-
externboolDatumIsReadWriteExpandedObject(Datumd,boolisnull,int16typlen);
147-
externDatumMakeExpandedObjectReadOnly(Datumd,boolisnull,int16typlen);
155+
externDatumMakeExpandedObjectReadOnlyInternal(Datumd);
148156
externDatumTransferExpandedObject(Datumd,MemoryContextnew_parent);
149157
externvoidDeleteExpandedObject(Datumd);
150158

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp