The FuncDev.nArg field values -3 and -4 now have special meansing of 1 or more
or 2 or more arguments, respectively. This saves space in the built-in function table, resulting in slightly faster performance and a reduced binary size. FossilOrigin-Name: 753fd747f24c5e9a019eb00b8a4f66e65c6733ba10a7adbd1b55786867c32ca6
This commit is contained in:
+8
-2
@@ -302,12 +302,18 @@ static int matchQuality(
|
||||
u8 enc /* Desired text encoding */
|
||||
){
|
||||
int match;
|
||||
assert( p->nArg>=-1 );
|
||||
assert( p->nArg>=(-4) && p->nArg!=(-2) );
|
||||
assert( nArg>=(-2) );
|
||||
|
||||
/* Wrong number of arguments means "no match" */
|
||||
if( p->nArg!=nArg ){
|
||||
if( nArg==(-2) ) return (p->xSFunc==0) ? 0 : FUNC_PERFECT_MATCH;
|
||||
if( nArg==(-2) ) return p->xSFunc==0 ? 0 : FUNC_PERFECT_MATCH;
|
||||
if( p->nArg>=0 ) return 0;
|
||||
/* Special p->nArg values available to built-in functions only:
|
||||
** -3 1 or more arguments required
|
||||
** -4 2 or more arguments required
|
||||
*/
|
||||
if( p->nArg<(-2) && nArg<(-2-p->nArg) ) return 0;
|
||||
}
|
||||
|
||||
/* Give a better score to a function with a specific number of arguments
|
||||
|
||||
+5
-12
@@ -2695,12 +2695,10 @@ void sqlite3RegisterBuiltinFunctions(void){
|
||||
FUNCTION(rtrim, 2, 2, 0, trimFunc ),
|
||||
FUNCTION(trim, 1, 3, 0, trimFunc ),
|
||||
FUNCTION(trim, 2, 3, 0, trimFunc ),
|
||||
FUNCTION(min, -1, 0, 1, minmaxFunc ),
|
||||
FUNCTION(min, 0, 0, 1, 0 ),
|
||||
FUNCTION(min, -3, 0, 1, minmaxFunc ),
|
||||
WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
|
||||
SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
|
||||
FUNCTION(max, -1, 1, 1, minmaxFunc ),
|
||||
FUNCTION(max, 0, 1, 1, 0 ),
|
||||
FUNCTION(max, -3, 1, 1, minmaxFunc ),
|
||||
WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
|
||||
SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
|
||||
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
|
||||
@@ -2727,11 +2725,8 @@ void sqlite3RegisterBuiltinFunctions(void){
|
||||
FUNCTION(hex, 1, 0, 0, hexFunc ),
|
||||
FUNCTION(unhex, 1, 0, 0, unhexFunc ),
|
||||
FUNCTION(unhex, 2, 0, 0, unhexFunc ),
|
||||
FUNCTION(concat, -1, 0, 0, concatFunc ),
|
||||
FUNCTION(concat, 0, 0, 0, 0 ),
|
||||
FUNCTION(concat_ws, -1, 0, 0, concatwsFunc ),
|
||||
FUNCTION(concat_ws, 0, 0, 0, 0 ),
|
||||
FUNCTION(concat_ws, 1, 0, 0, 0 ),
|
||||
FUNCTION(concat, -3, 0, 0, concatFunc ),
|
||||
FUNCTION(concat_ws, -4, 0, 0, concatwsFunc ),
|
||||
INLINE_FUNC(ifnull, 2, INLINEFUNC_coalesce, 0 ),
|
||||
VFUNCTION(random, 0, 0, 0, randomFunc ),
|
||||
VFUNCTION(randomblob, 1, 0, 0, randomBlob ),
|
||||
@@ -2775,8 +2770,6 @@ void sqlite3RegisterBuiltinFunctions(void){
|
||||
#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
|
||||
FUNCTION(unknown, -1, 0, 0, unknownFunc ),
|
||||
#endif
|
||||
FUNCTION(coalesce, 1, 0, 0, 0 ),
|
||||
FUNCTION(coalesce, 0, 0, 0, 0 ),
|
||||
#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
|
||||
MFUNCTION(ceil, 1, xCeil, ceilingFunc ),
|
||||
MFUNCTION(ceiling, 1, xCeil, ceilingFunc ),
|
||||
@@ -2814,7 +2807,7 @@ void sqlite3RegisterBuiltinFunctions(void){
|
||||
MFUNCTION(pi, 0, 0, piFunc ),
|
||||
#endif /* SQLITE_ENABLE_MATH_FUNCTIONS */
|
||||
FUNCTION(sign, 1, 0, 0, signFunc ),
|
||||
INLINE_FUNC(coalesce, -1, INLINEFUNC_coalesce, 0 ),
|
||||
INLINE_FUNC(coalesce, -4, INLINEFUNC_coalesce, 0 ),
|
||||
INLINE_FUNC(iif, 2, INLINEFUNC_iif, 0 ),
|
||||
INLINE_FUNC(iif, 3, INLINEFUNC_iif, 0 ),
|
||||
INLINE_FUNC(if, 2, INLINEFUNC_iif, 0 ),
|
||||
|
||||
Reference in New Issue
Block a user