Faster implementation for sqlite3VdbeIntValue() and sqlite3VdbeRealValue().

FossilOrigin-Name: 8698df60c23d4dcc80b58352c14ae80ec238cac496f8a87bd72a96fef61cc63f
This commit is contained in:
drh 2017-04-01 11:59:36 +00:00
parent b6017a44c5
commit b808d77771
3 changed files with 21 additions and 15 deletions

View File

@ -1,5 +1,5 @@
C Remove\sunused\sfields\sfrom\sthe\sBtCursor\sobject.
D 2017-04-01T11:40:05.090
C Faster\simplementation\sfor\ssqlite3VdbeIntValue()\sand\ssqlite3VdbeRealValue().
D 2017-04-01T11:59:36.584
F Makefile.in 1cc758ce3374a32425e4d130c2fe7b026b20de5b8843243de75f087c0a2661fb
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
F Makefile.msc a4c0613a18663bda56d8cf76079ab6590a7c3602e54befb4bbdef76bcaa38b6a
@ -474,7 +474,7 @@ F src/vdbeInt.h 5db089ce18c4feff8820ec6e4cac2d2c82e03d4b1d96f10a6e43832147b8dffe
F src/vdbeapi.c 5b08d82592bcff4470601fe78aaabebd50837860
F src/vdbeaux.c ecd0468611925d218e1eb4b3f538907904b136f0e15e333291a232b521bfcef1
F src/vdbeblob.c 359891617358deefc85bef7bcf787fa6b77facb9
F src/vdbemem.c 3b5a9a5b375458d3e12a50ae1aaa41eeec2175fd
F src/vdbemem.c bbd8f5fdb7f11e02d9a6201f18a52325f1d2361a2850ff03a38f8efa5188f2dc
F src/vdbesort.c eda25cb2d1727efca6f7862fea32b8aa33c0face
F src/vdbetrace.c 41963d5376f0349842b5fc4aaaaacd7d9cdc0834
F src/vtab.c 007513c2ef52472fcdea6a741683d50662e82790
@ -1569,7 +1569,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 2452f0617d1085689264b5f66681788cfe9e3b1a7b318307c93942b702a443df
R a9b36ce777e90549c853b64c225197a6
P 1c0d82e0786ed22d07d774b8b166340fad97bcaab6016e395c469bcfcb7c77a3
R e7e1f4a4fa7fe0c6a0bd77f428c6873c
U drh
Z 4b939d3dd6a7f0c2f29593c397a2c2a8
Z b92e301c12dc9a925621c9624fd5cc90

View File

@ -1 +1 @@
1c0d82e0786ed22d07d774b8b166340fad97bcaab6016e395c469bcfcb7c77a3
8698df60c23d4dcc80b58352c14ae80ec238cac496f8a87bd72a96fef61cc63f

View File

@ -420,7 +420,7 @@ void sqlite3VdbeMemRelease(Mem *p){
** If the double is out of range of a 64-bit signed integer then
** return the closest available 64-bit signed integer.
*/
static i64 doubleToInt64(double r){
static SQLITE_NOINLINE i64 doubleToInt64(double r){
#ifdef SQLITE_OMIT_FLOATING_POINT
/* When floating-point is omitted, double and int64 are the same thing */
return r;
@ -456,6 +456,11 @@ static i64 doubleToInt64(double r){
**
** If pMem represents a string value, its encoding might be changed.
*/
static SQLITE_NOINLINE i64 memIntValue(Mem *pMem){
i64 value = 0;
sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
return value;
}
i64 sqlite3VdbeIntValue(Mem *pMem){
int flags;
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
@ -466,10 +471,8 @@ i64 sqlite3VdbeIntValue(Mem *pMem){
}else if( flags & MEM_Real ){
return doubleToInt64(pMem->u.r);
}else if( flags & (MEM_Str|MEM_Blob) ){
i64 value = 0;
assert( pMem->z || pMem->n==0 );
sqlite3Atoi64(pMem->z, &value, pMem->n, pMem->enc);
return value;
return memIntValue(pMem);
}else{
return 0;
}
@ -481,6 +484,12 @@ i64 sqlite3VdbeIntValue(Mem *pMem){
** value. If it is a string or blob, try to convert it to a double.
** If it is a NULL, return 0.0.
*/
static SQLITE_NOINLINE double memRealValue(Mem *pMem){
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
double val = (double)0;
sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
return val;
}
double sqlite3VdbeRealValue(Mem *pMem){
assert( pMem->db==0 || sqlite3_mutex_held(pMem->db->mutex) );
assert( EIGHT_BYTE_ALIGNMENT(pMem) );
@ -489,10 +498,7 @@ double sqlite3VdbeRealValue(Mem *pMem){
}else if( pMem->flags & MEM_Int ){
return (double)pMem->u.i;
}else if( pMem->flags & (MEM_Str|MEM_Blob) ){
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
double val = (double)0;
sqlite3AtoF(pMem->z, &val, pMem->n, pMem->enc);
return val;
return memRealValue(pMem);
}else{
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
return (double)0;