Avoid unnecessary calls to sqlite3VdbeSerialTypeLen() for integer

serial types, for a small size reduction and a speed increase.

FossilOrigin-Name: 9cd30d33b1d02dc8c55c1d74bdbcefab63ebf2a7
This commit is contained in:
drh 2015-06-28 02:58:51 +00:00
parent c75d886b05
commit c5ef7151b0
3 changed files with 17 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Make\sgreater\suse\sof\sBtCursor.curIntKey.
D 2015-06-27T23:55:20.211
C Avoid\sunnecessary\scalls\sto\ssqlite3VdbeSerialTypeLen()\sfor\sinteger\nserial\stypes,\sfor\sa\ssmall\ssize\sreduction\sand\sa\sspeed\sincrease.
D 2015-06-28T02:58:51.359
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 285a0a234ed7610d431d91671c136098c2bd86a9
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -394,7 +394,7 @@ F src/vdbe.c 3d5a78d39b15dc91ea2c11017d560a4224eb2f75
F src/vdbe.h 7a75045d879118b9d3af7e8b3c108f2f27c51473
F src/vdbeInt.h 8b54e01ad0463590e7cffabce0bc36da9ee4f816
F src/vdbeapi.c 6a0d7757987018ff6b1b81bc5293219cd26bb299
F src/vdbeaux.c 13261b7597c7f189232f84a1e175a3268ea2c32b
F src/vdbeaux.c 54bcc56d368b2d0bebc523cff514893156c09daf
F src/vdbeblob.c 4f2e8e075d238392df98c5e03a64342465b03f90
F src/vdbemem.c ae38a0d35ae71cf604381a887c170466ba518090
F src/vdbesort.c f5009e7a35e3065635d8918b9a31f498a499976b
@ -1364,7 +1364,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 4a17df139ac41e29c9a2e58afbd1238a5e94bd36
R 951a5590bfe7a8b4e737119af9769202
P 63998471d023dd846d5583ac856e2acc47ad41ea
R 212ca1fcb98a576a11f4bdf11ee3ebc0
U drh
Z 51f9425184670e22671d083e0bae99bd
Z 171de1cc147222ccddab9bfa4a1ca423

View File

@ -1 +1 @@
63998471d023dd846d5583ac856e2acc47ad41ea
9cd30d33b1d02dc8c55c1d74bdbcefab63ebf2a7

View File

@ -2961,6 +2961,13 @@ u32 sqlite3VdbeSerialType(Mem *pMem, int file_format){
return ((n*2) + 12 + ((flags&MEM_Str)!=0));
}
/*
** The sizes for serial types less than 12
*/
static const u8 sqlite3SmallTypeSizes[] = {
0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0
};
/*
** Return the length of the data corresponding to the supplied serial-type.
*/
@ -2968,8 +2975,7 @@ u32 sqlite3VdbeSerialTypeLen(u32 serial_type){
if( serial_type>=12 ){
return (serial_type-12)/2;
}else{
static const u8 aSize[] = { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0, 0, 0 };
return aSize[serial_type];
return sqlite3SmallTypeSizes[serial_type];
}
}
@ -3053,7 +3059,7 @@ u32 sqlite3VdbeSerialPut(u8 *buf, Mem *pMem, u32 serial_type){
}else{
v = pMem->u.i;
}
len = i = sqlite3VdbeSerialTypeLen(serial_type);
len = i = sqlite3SmallTypeSizes[serial_type];
assert( i>0 );
do{
buf[--i] = (u8)(v&0xFF);
@ -4082,7 +4088,7 @@ int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){
if( unlikely(typeRowid<1 || typeRowid>9 || typeRowid==7) ){
goto idx_rowid_corruption;
}
lenRowid = sqlite3VdbeSerialTypeLen(typeRowid);
lenRowid = sqlite3SmallTypeSizes[typeRowid];
testcase( (u32)m.n==szHdr+lenRowid );
if( unlikely((u32)m.n<szHdr+lenRowid) ){
goto idx_rowid_corruption;