Tighten coding of fmgr_isbuiltin() ... managed to speed it up
by about 10% which seems to be good for half a percent or so of a SELECT.
This commit is contained in:
parent
49b6be244c
commit
443e24beb7
@ -8,7 +8,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.12 1998/10/28 19:38:47 tgl Exp $
|
# $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $
|
||||||
#
|
#
|
||||||
# NOTES
|
# NOTES
|
||||||
# Passes any -D options on to cpp prior to generating the list
|
# Passes any -D options on to cpp prior to generating the list
|
||||||
@ -83,7 +83,7 @@ cat > $HFILE <<FuNkYfMgRsTuFf
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: Gen_fmgrtab.sh.in,v 1.12 1998/10/28 19:38:47 tgl Exp $
|
* $Id: Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* ******************************
|
* ******************************
|
||||||
@ -197,7 +197,7 @@ cat > $TABCFILE <<FuNkYfMgRtAbStUfF
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.12 1998/10/28 19:38:47 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/backend/utils/Attic/Gen_fmgrtab.sh.in,v 1.13 1999/01/25 00:44:53 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@ -250,36 +250,38 @@ cat >> $TABCFILE <<FuNkYfMgRtAbStUfF
|
|||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int fmgr_nbuiltins = (sizeof(fmgr_builtins) / sizeof(FmgrCall)) - 1;
|
/* Note FMGR_NBUILTINS excludes the guardian entry, which is probably
|
||||||
|
* not really needed at all ...
|
||||||
|
*/
|
||||||
|
#define FMGR_NBUILTINS ((sizeof(fmgr_builtins) / sizeof(FmgrCall)) - 1)
|
||||||
|
|
||||||
FmgrCall *fmgr_isbuiltin(Oid id)
|
FmgrCall *fmgr_isbuiltin(Oid id)
|
||||||
{
|
{
|
||||||
register int i = 0;
|
|
||||||
int low = 0;
|
int low = 0;
|
||||||
int high = fmgr_nbuiltins;
|
int high = FMGR_NBUILTINS - 1;
|
||||||
|
|
||||||
low = 0;
|
/* Loop invariant: low is the first index that could contain target
|
||||||
high = fmgr_nbuiltins;
|
* entry, and high is the last index that could contain it.
|
||||||
while (low <= high) {
|
*/
|
||||||
i = low + (high - low) / 2;
|
while (low <= high) {
|
||||||
if (id == fmgr_builtins[i].proid)
|
int i = (high + low) / 2;
|
||||||
break;
|
FmgrCall * ptr = &fmgr_builtins[i];
|
||||||
else if (id > fmgr_builtins[i].proid)
|
if (id == ptr->proid)
|
||||||
low = i + 1;
|
return ptr;
|
||||||
else
|
else if (id > ptr->proid)
|
||||||
high = i - 1;
|
low = i + 1;
|
||||||
}
|
else
|
||||||
if (id == fmgr_builtins[i].proid)
|
high = i - 1;
|
||||||
return(&fmgr_builtins[i]);
|
}
|
||||||
return((FmgrCall *) NULL);
|
return (FmgrCall *) NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
func_ptr fmgr_lookupByName(char *name)
|
func_ptr fmgr_lookupByName(char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<fmgr_nbuiltins;i++) {
|
for (i=0; i<FMGR_NBUILTINS; i++) {
|
||||||
if (strcmp(name,fmgr_builtins[i].funcName) == 0)
|
if (strcmp(name,fmgr_builtins[i].funcName) == 0)
|
||||||
return(fmgr_builtins[i].func);
|
return(fmgr_builtins[i].func);
|
||||||
}
|
}
|
||||||
return((func_ptr) NULL);
|
return((func_ptr) NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user