mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Performance enhancement in sqlite3PutVarint().
FossilOrigin-Name: a929be551924144c9bc7aab608404d59e479abb5
This commit is contained in:
16
manifest
16
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Split\sthe\ssqlite3Error()\sroutine\sinto\ssqlite3Error()\sand\nsqlite3ErrorWithMsg(),\sfor\sa\sslight\ssize\sreduction\sand\sperformance\sincrease.
|
C Performance\senhancement\sin\ssqlite3PutVarint().
|
||||||
D 2014-08-22T18:00:11.621
|
D 2014-08-22T18:48:25.634
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
|
F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -228,7 +228,7 @@ F src/shell.c 728d2226594d356bf4fbdbdfd08538fd78fd06f3
|
|||||||
F src/sqlite.h.in ed9d35990c61f0388ca6405706455c4095310553
|
F src/sqlite.h.in ed9d35990c61f0388ca6405706455c4095310553
|
||||||
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
F src/sqlite3.rc 992c9f5fb8285ae285d6be28240a7e8d3a7f2bad
|
||||||
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
|
F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc
|
||||||
F src/sqliteInt.h 937869c407c61026443c879e8c90a9dff05d2d27
|
F src/sqliteInt.h d8a9be2aa123a78c90ad4aba09b23e7dd3f8cc9f
|
||||||
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d
|
||||||
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
|
F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158
|
||||||
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e
|
||||||
@@ -282,7 +282,7 @@ F src/tokenize.c ae45399d6252b4d736af43bee1576ce7bff86aec
|
|||||||
F src/trigger.c 4bddd12803275aa98f1c7ce0118fceb02b2167f6
|
F src/trigger.c 4bddd12803275aa98f1c7ce0118fceb02b2167f6
|
||||||
F src/update.c ea336ce7b8b3fc5e316ba8f082e6445babf81059
|
F src/update.c ea336ce7b8b3fc5e316ba8f082e6445babf81059
|
||||||
F src/utf.c a0314e637768a030e6e84a957d0c4f6ba910cc05
|
F src/utf.c a0314e637768a030e6e84a957d0c4f6ba910cc05
|
||||||
F src/util.c 524127b3c330b9f490a505ff6eb7f80dfc873a3a
|
F src/util.c 068dcd26354a3898ccc64ad5c4bdb95a7a15d33a
|
||||||
F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
|
F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179
|
||||||
F src/vdbe.c f7f4066e4d6e3858878d76ce9288ea603e12ddf6
|
F src/vdbe.c f7f4066e4d6e3858878d76ce9288ea603e12ddf6
|
||||||
F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8
|
F src/vdbe.h c63fad052c9e7388d551e556e119c0bcf6bebdf8
|
||||||
@@ -290,7 +290,7 @@ F src/vdbeInt.h f5513f2b5ac1e2c5128996c7ea23add256a301df
|
|||||||
F src/vdbeapi.c 49b8d2943d02d276b4efef114578251a3277f47d
|
F src/vdbeapi.c 49b8d2943d02d276b4efef114578251a3277f47d
|
||||||
F src/vdbeaux.c f7fdc59e2eefa6fc4ba7324b03ea6f8f66e98d62
|
F src/vdbeaux.c f7fdc59e2eefa6fc4ba7324b03ea6f8f66e98d62
|
||||||
F src/vdbeblob.c 848238dc73e93e48432991bb5651bf87d865eca4
|
F src/vdbeblob.c 848238dc73e93e48432991bb5651bf87d865eca4
|
||||||
F src/vdbemem.c d90a1e8acf8b63dc9d14cbbea12bfec6cec31394
|
F src/vdbemem.c 4a64659ed8e4c3b18a9238e038145ab1bdcd146f
|
||||||
F src/vdbesort.c f7f5563bf7d4695ca8f3203f3bf9de96d04ed0b3
|
F src/vdbesort.c f7f5563bf7d4695ca8f3203f3bf9de96d04ed0b3
|
||||||
F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
|
F src/vdbetrace.c 6f52bc0c51e144b7efdcfb2a8f771167a8816767
|
||||||
F src/vtab.c 019dbfd0406a7447c990e1f7bd1dfcdb8895697f
|
F src/vtab.c 019dbfd0406a7447c990e1f7bd1dfcdb8895697f
|
||||||
@@ -1188,7 +1188,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
|
|||||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||||
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
|
||||||
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
|
||||||
P f7f2160db014f0ae11ad13c8ad70ad3444124e3e
|
P cf561d1f0bb60b3d638632d20bd686dda4fa4a04
|
||||||
R 668369bbbf2d81407f36345226c5d2a9
|
R 892fbe852e37f91de1b9f5afa35c0502
|
||||||
U drh
|
U drh
|
||||||
Z bddb035a8072a327798c78fbe23bcf26
|
Z c70614e9322ab39ef4e9fbe07eb13b05
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
cf561d1f0bb60b3d638632d20bd686dda4fa4a04
|
a929be551924144c9bc7aab608404d59e479abb5
|
||||||
@@ -3307,38 +3307,23 @@ u64 sqlite3LogEstToInt(LogEst);
|
|||||||
/*
|
/*
|
||||||
** Routines to read and write variable-length integers. These used to
|
** Routines to read and write variable-length integers. These used to
|
||||||
** be defined locally, but now we use the varint routines in the util.c
|
** be defined locally, but now we use the varint routines in the util.c
|
||||||
** file. Code should use the MACRO forms below, as the Varint32 versions
|
** file.
|
||||||
** are coded to assume the single byte case is already handled (which
|
|
||||||
** the MACRO form does).
|
|
||||||
*/
|
*/
|
||||||
int sqlite3PutVarint(unsigned char*, u64);
|
int sqlite3PutVarint(unsigned char*, u64);
|
||||||
int sqlite3PutVarint32(unsigned char*, u32);
|
|
||||||
u8 sqlite3GetVarint(const unsigned char *, u64 *);
|
u8 sqlite3GetVarint(const unsigned char *, u64 *);
|
||||||
u8 sqlite3GetVarint32(const unsigned char *, u32 *);
|
u8 sqlite3GetVarint32(const unsigned char *, u32 *);
|
||||||
int sqlite3VarintLen(u64 v);
|
int sqlite3VarintLen(u64 v);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** The header of a record consists of a sequence variable-length integers.
|
** The common case is for a varint to be a single byte. They following
|
||||||
** These integers are almost always small and are encoded as a single byte.
|
** macros handle the common case without a procedure call, but then call
|
||||||
** The following macros take advantage this fact to provide a fast encode
|
** the procedure for larger varints.
|
||||||
** and decode of the integers in a record header. It is faster for the common
|
|
||||||
** case where the integer is a single byte. It is a little slower when the
|
|
||||||
** integer is two or more bytes. But overall it is faster.
|
|
||||||
**
|
|
||||||
** The following expressions are equivalent:
|
|
||||||
**
|
|
||||||
** x = sqlite3GetVarint32( A, &B );
|
|
||||||
** x = sqlite3PutVarint32( A, B );
|
|
||||||
**
|
|
||||||
** x = getVarint32( A, B );
|
|
||||||
** x = putVarint32( A, B );
|
|
||||||
**
|
|
||||||
*/
|
*/
|
||||||
#define getVarint32(A,B) \
|
#define getVarint32(A,B) \
|
||||||
(u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))
|
(u8)((*(A)<(u8)0x80)?((B)=(u32)*(A)),1:sqlite3GetVarint32((A),(u32 *)&(B)))
|
||||||
#define putVarint32(A,B) \
|
#define putVarint32(A,B) \
|
||||||
(u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\
|
(u8)(((u32)(B)<(u32)0x80)?(*(A)=(unsigned char)(B)),1:\
|
||||||
sqlite3PutVarint32((A),(B)))
|
sqlite3PutVarint((A),(B)))
|
||||||
#define getVarint sqlite3GetVarint
|
#define getVarint sqlite3GetVarint
|
||||||
#define putVarint sqlite3PutVarint
|
#define putVarint sqlite3PutVarint
|
||||||
|
|
||||||
|
|||||||
27
src/util.c
27
src/util.c
@@ -708,7 +708,7 @@ int sqlite3Atoi(const char *z){
|
|||||||
** bit clear. Except, if we get to the 9th byte, it stores the full
|
** bit clear. Except, if we get to the 9th byte, it stores the full
|
||||||
** 8 bits and is the last byte.
|
** 8 bits and is the last byte.
|
||||||
*/
|
*/
|
||||||
int sqlite3PutVarint(unsigned char *p, u64 v){
|
static int SQLITE_NOINLINE putVarint64(unsigned char *p, u64 v){
|
||||||
int i, j, n;
|
int i, j, n;
|
||||||
u8 buf[10];
|
u8 buf[10];
|
||||||
if( v & (((u64)0xff000000)<<32) ){
|
if( v & (((u64)0xff000000)<<32) ){
|
||||||
@@ -732,28 +732,17 @@ int sqlite3PutVarint(unsigned char *p, u64 v){
|
|||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
int sqlite3PutVarint(unsigned char *p, u64 v){
|
||||||
/*
|
if( v<=0x7f ){
|
||||||
** This routine is a faster version of sqlite3PutVarint() that only
|
p[0] = v&0x7f;
|
||||||
** works for 32-bit positive integers and which is optimized for
|
|
||||||
** the common case of small integers. A MACRO version, putVarint32,
|
|
||||||
** is provided which inlines the single-byte case. All code should use
|
|
||||||
** the MACRO version as this function assumes the single-byte case has
|
|
||||||
** already been handled.
|
|
||||||
*/
|
|
||||||
int sqlite3PutVarint32(unsigned char *p, u32 v){
|
|
||||||
#ifndef putVarint32
|
|
||||||
if( (v & ~0x7f)==0 ){
|
|
||||||
p[0] = v;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
#endif
|
if( v<=0x3fff ){
|
||||||
if( (v & ~0x3fff)==0 ){
|
p[0] = ((v>>7)&0x7f)|0x80;
|
||||||
p[0] = (u8)((v>>7) | 0x80);
|
p[1] = v&0x7f;
|
||||||
p[1] = (u8)(v & 0x7f);
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
return sqlite3PutVarint(p, v);
|
return putVarint64(p,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1130,7 +1130,7 @@ static void recordFunc(
|
|||||||
sqlite3_result_error_nomem(context);
|
sqlite3_result_error_nomem(context);
|
||||||
}else{
|
}else{
|
||||||
aRet[0] = nSerial+1;
|
aRet[0] = nSerial+1;
|
||||||
sqlite3PutVarint(&aRet[1], iSerial);
|
putVarint32(&aRet[1], iSerial);
|
||||||
sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial);
|
sqlite3VdbeSerialPut(&aRet[1+nSerial], argv[0], iSerial);
|
||||||
sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);
|
sqlite3_result_blob(context, aRet, nRet, SQLITE_TRANSIENT);
|
||||||
sqlite3DbFree(db, aRet);
|
sqlite3DbFree(db, aRet);
|
||||||
|
|||||||
Reference in New Issue
Block a user