Re: [HACKERS] inlining
Bruce Momjian <maillist@candle.pha.pa.us>
From: Bruce Momjian <maillist@candle.pha.pa.us>
To: vadim@sable.krasnoyarsk.su (Vadim B. Mikheev)
Cc: hackers@postgreSQL.org
Date: 1998-01-30T15:59:15Z
Lists: pgsql-hackers
> > Bruce Momjian wrote: > > > > Let me add, I am not inlining all the functions, but only the top part > > of them that deals with cachoffsets and nulls. These are the easy ones, > > and the ones that get used most often. > > fastgetattr() is called from a HUNDREDS places - I'm not sure that > this is good idea. Here is the fastgetattr macro. Again, I just inlined the cacheoffset and null handlling at the top. Doesn't look like much code, though the ?: macro format makes it look larger. What do you think? I did the same with fastgetiattr, which in fact just called index_getattr, so that is gone now. For getsysattr, I made an array of offsetof(), and do a lookup into the array from heap_getattr, so that is gone too. --------------------------------------------------------------------------- #define fastgetattr(tup, attnum, tupleDesc, isnull) \ ( \ AssertMacro((attnum) > 0) ? \ ( \ ((isnull) ? (*(isnull) = false) : (dummyret)NULL), \ HeapTupleNoNulls(tup) ? \ ( \ ((tupleDesc)->attrs[(attnum)-1]->attcacheoff > 0) ? \ ( \ (Datum)fetchatt(&((tupleDesc)->attrs[(attnum)-1]), \ (char *) (tup) + (tup)->t_hoff + (tupleDesc)->attrs[(attnum)-1]->attcacheoff) \ ) \ : \ ( \ ((attnum)-1 > 0) ? \ ( \ (Datum)fetchatt(&((tupleDesc)->attrs[0]), (char *) (tup) + (tup)->t_hoff) \ ) \ : \ ( \ nocachegetattr((tup), (attnum), (tupleDesc), (isnull)) \ ) \ ) \ ) \ : \ ( \ att_isnull((attnum)-1, (tup)->t_bits) ? \ ( \ ((isnull) ? (*(isnull) = true) : (dummyret)NULL), \ (Datum)NULL \ ) \ : \ ( \ nocachegetattr((tup), (attnum), (tupleDesc), (isnull)) \ ) \ ) \ ) \ : \ ( \ (Datum)NULL \ ) \ ) > > I suggest to inline _entire_ body of this func in the > execQual.c:ExecEvalVar() - Executor uses _only_ ExecEvalVar() to get > data from tuples. > > (We could #define FASTGETATTR macro and re-write fastgetattr() as just > this macro "call".) > > I don't know should we follow the same way for fastgetiattr() or not... > > Vadim > -- Bruce Momjian maillist@candle.pha.pa.us