From 56690b3d4935766cbe6a2d936e6371b03232ac04 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Sep 2012 15:36:31 +0000 Subject: [PATCH 1/4] Performance enhancement in the sqlite3VdbeSerialType() routine. FossilOrigin-Name: ad298f52efd0ff123a1a4d6a0fa16fbd4c6b6dad --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeaux.c | 7 +++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 816c07ad80..0a9b567d70 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\sname\sof\srollback\sjournal\sfiles\sare\sdouble-zero\sterminated\nwhen\sthey\sare\spassed\sinto\sthe\sVFS. -D 2012-09-15T13:39:24.735 +C Performance\senhancement\sin\sthe\ssqlite3VdbeSerialType()\sroutine. +D 2012-09-17T15:36:31.241 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -240,7 +240,7 @@ F src/vdbe.c fd82787f9fb5bfb48dea822d41f28c2a73c25e2e F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb F src/vdbeInt.h a668b303644377433e31a18d3d9efb87eefb6332 F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c -F src/vdbeaux.c 9c293fd3040211687e83d5d27bef2382933146c2 +F src/vdbeaux.c aeeee6c97e0c2ad31c376a781cb7462090b9827b F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c 0dc1b274dcb4d4c8e71b0b2b15261f286caba39b @@ -1013,7 +1013,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P a93ee09cdc15987848bf9023e69892ce9a5f989e -R ecaebb814f51bb6e38f5c9d70e5c1467 +P 8711a8447d28275602287faf533de3d6e50d535d +R 34d4f192c96f51569b1d84a4c81787ab U drh -Z a699a11a3dac3cfd2b9a3a76bfd53ddc +Z c99f61ab4f3b0b408fc647ac1fcea198 diff --git a/manifest.uuid b/manifest.uuid index e60e09e0ac..3a105ea7dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8711a8447d28275602287faf533de3d6e50d535d \ No newline at end of file +ad298f52efd0ff123a1a4d6a0fa16fbd4c6b6dad \ No newline at end of file diff --git a/src/vdbeaux.c b/src/vdbeaux.c index d4f9864b14..dd23d395bd 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2583,9 +2583,6 @@ u32 sqlite3VdbeSerialType(Mem *pMem, int file_format){ # define MAX_6BYTE ((((i64)0x00008000)<<32)-1) i64 i = pMem->u.i; u64 u; - if( file_format>=4 && (i&1)==i ){ - return 8+(u32)i; - } if( i<0 ){ if( i<(-MAX_6BYTE) ) return 6; /* Previous test prevents: u = -(-9223372036854775808) */ @@ -2593,7 +2590,9 @@ u32 sqlite3VdbeSerialType(Mem *pMem, int file_format){ }else{ u = i; } - if( u<=127 ) return 1; + if( u<=127 ){ + return ((i&1)==i && file_format>=4) ? 8+(u32)u : 1; + } if( u<=32767 ) return 2; if( u<=8388607 ) return 3; if( u<=2147483647 ) return 4; From e1a022e48be1e7f40a8310e0f917fac8593c66a4 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Sep 2012 17:16:53 +0000 Subject: [PATCH 2/4] Make sure the KeyInfo.aSortOrder array is always allocated so that we never have to test for KeyInfo.aSortOrder==0 in performance-critical loops. FossilOrigin-Name: 45793f0b844fee7445bc9269b403f89a58f77150 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/expr.c | 3 +++ src/select.c | 1 + src/vdbeaux.c | 14 ++++++++------ 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 0a9b567d70..949d71190f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\senhancement\sin\sthe\ssqlite3VdbeSerialType()\sroutine. -D 2012-09-17T15:36:31.241 +C Make\ssure\sthe\sKeyInfo.aSortOrder\sarray\sis\salways\sallocated\sso\sthat\swe\snever\nhave\sto\stest\sfor\sKeyInfo.aSortOrder==0\sin\sperformance-critical\sloops. +D 2012-09-17T17:16:53.958 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -130,7 +130,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 72a70dcfda75d3a1f81041ce4573e7afddcd8e4e F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c 335f36750dc6ac88d580aa36a6487459be9889de -F src/expr.c 217840a107dcc1e5dbb57cea311daad04bedbb9a +F src/expr.c 70ded09d6ac529718aec57589ddb378c23153693 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c c82a04e7a92bb728f9ab972b76590403283be2af F src/func.c b4e88b92838fdab8e0088cc8411c06664b4dcf55 @@ -174,7 +174,7 @@ F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c 9e28280ec98035f31900fdd1db01f86f68ca6c32 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 -F src/select.c 171ec5fd5eae6d7a19b54f8f0abdfdd9a1c8f3ad +F src/select.c 1278b07a8c9a7f2f65b8efa8565993a56c4a58a3 F src/shell.c 87953c5d9c73d9494db97d1607e2e2280418f261 F src/sqlite.h.in d1071b0fc6de9a0d11392bc01305803122c3ec61 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 @@ -240,7 +240,7 @@ F src/vdbe.c fd82787f9fb5bfb48dea822d41f28c2a73c25e2e F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb F src/vdbeInt.h a668b303644377433e31a18d3d9efb87eefb6332 F src/vdbeapi.c 4c2418161cf45392ba76a7ca92f9a5f06b96f89c -F src/vdbeaux.c aeeee6c97e0c2ad31c376a781cb7462090b9827b +F src/vdbeaux.c fac025c798ad19070451b41eddc5dcd4696fdd1e F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c 0dc1b274dcb4d4c8e71b0b2b15261f286caba39b @@ -1013,7 +1013,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 8711a8447d28275602287faf533de3d6e50d535d -R 34d4f192c96f51569b1d84a4c81787ab +P ad298f52efd0ff123a1a4d6a0fa16fbd4c6b6dad +R 399ab3eadb581c96415fb9d89f0fbcd1 U drh -Z c99f61ab4f3b0b408fc647ac1fcea198 +Z 939733a13ef406dcc12020fe5915f839 diff --git a/manifest.uuid b/manifest.uuid index 3a105ea7dc..ddfbcb8578 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ad298f52efd0ff123a1a4d6a0fa16fbd4c6b6dad \ No newline at end of file +45793f0b844fee7445bc9269b403f89a58f77150 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 89172f94bf..3fb51cf11f 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1662,6 +1662,7 @@ int sqlite3CodeSubselect( case TK_IN: { char affinity; /* Affinity of the LHS of the IN */ KeyInfo keyInfo; /* Keyinfo for the generated table */ + static u8 sortOrder = 0; /* Fake aSortOrder for keyInfo */ int addr; /* Address of OP_OpenEphemeral instruction */ Expr *pLeft = pExpr->pLeft; /* the LHS of the IN operator */ @@ -1689,6 +1690,7 @@ int sqlite3CodeSubselect( if( rMayHaveNull==0 ) sqlite3VdbeChangeP5(v, BTREE_UNORDERED); memset(&keyInfo, 0, sizeof(keyInfo)); keyInfo.nField = 1; + keyInfo.aSortOrder = &sortOrder; if( ExprHasProperty(pExpr, EP_xIsSelect) ){ /* Case 1: expr IN (SELECT ...) @@ -1729,6 +1731,7 @@ int sqlite3CodeSubselect( affinity = SQLITE_AFF_NONE; } keyInfo.aColl[0] = sqlite3ExprCollSeq(pParse, pExpr->pLeft); + keyInfo.aSortOrder = &sortOrder; /* Loop through each expression in . */ r1 = sqlite3GetTempReg(pParse); diff --git a/src/select.c b/src/select.c index 0bf47e8521..656f39d6e8 100644 --- a/src/select.c +++ b/src/select.c @@ -1892,6 +1892,7 @@ static int multiSelect( *apColl = db->pDfltColl; } } + pKeyInfo->aSortOrder = (u8*)apColl; for(pLoop=p; pLoop; pLoop=pLoop->pPrior){ for(i=0; i<2; i++){ diff --git a/src/vdbeaux.c b/src/vdbeaux.c index dd23d395bd..9db3bf435c 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -745,10 +745,9 @@ void sqlite3VdbeChangeP4(Vdbe *p, int addr, const char *zP4, int n){ u8 *aSortOrder; memcpy((char*)pKeyInfo, zP4, nByte - nField); aSortOrder = pKeyInfo->aSortOrder; - if( aSortOrder ){ - pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField]; - memcpy(pKeyInfo->aSortOrder, aSortOrder, nField); - } + assert( aSortOrder!=0 ); + pKeyInfo->aSortOrder = (unsigned char*)&pKeyInfo->aColl[nField]; + memcpy(pKeyInfo->aSortOrder, aSortOrder, nField); pOp->p4type = P4_KEYINFO; }else{ p->db->mallocFailed = 1; @@ -861,6 +860,7 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){ case P4_KEYINFO: { int i, j; KeyInfo *pKeyInfo = pOp->p4.pKeyInfo; + assert( pKeyInfo->aSortOrder!=0 ); sqlite3_snprintf(nTemp, zTemp, "keyinfo(%d", pKeyInfo->nField); i = sqlite3Strlen30(zTemp); for(j=0; jnField; j++){ @@ -872,7 +872,7 @@ static char *displayP4(Op *pOp, char *zTemp, int nTemp){ break; } zTemp[i++] = ','; - if( pKeyInfo->aSortOrder && pKeyInfo->aSortOrder[j] ){ + if( pKeyInfo->aSortOrder[j] ){ zTemp[i++] = '-'; } memcpy(&zTemp[i], pColl->zName,n+1); @@ -2877,6 +2877,7 @@ UnpackedRecord *sqlite3VdbeAllocUnpackedRecord( } p->aMem = (Mem*)&((char*)p)[ROUND8(sizeof(UnpackedRecord))]; + assert( pKeyInfo->aSortOrder!=0 ); p->pKeyInfo = pKeyInfo; p->nField = pKeyInfo->nField + 1; return p; @@ -2970,6 +2971,7 @@ int sqlite3VdbeRecordCompare( idx1 = getVarint32(aKey1, szHdr1); d1 = szHdr1; nField = pKeyInfo->nField; + assert( pKeyInfo->aSortOrder!=0 ); while( idx1nField ){ u32 serial_type1; @@ -2989,7 +2991,7 @@ int sqlite3VdbeRecordCompare( assert( mem1.zMalloc==0 ); /* See comment below */ /* Invert the result if we are using DESC sort order. */ - if( pKeyInfo->aSortOrder && iaSortOrder[i] ){ + if( iaSortOrder[i] ){ rc = -rc; } From 4261096124d777b383ae7db34f3752d01be05192 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Sep 2012 18:56:32 +0000 Subject: [PATCH 3/4] Remove an unnecessary parameter from sqlite3Utf8Read() resulting in a slight performance increase. FossilOrigin-Name: 8b962c94a2f829f71efdd0ca770469b02feea3e1 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/func.c | 38 +++++++++++++++++++------------------- src/sqliteInt.h | 2 +- src/utf.c | 16 ++++++---------- 5 files changed, 35 insertions(+), 39 deletions(-) diff --git a/manifest b/manifest index 949d71190f..92fce0dba0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\sKeyInfo.aSortOrder\sarray\sis\salways\sallocated\sso\sthat\swe\snever\nhave\sto\stest\sfor\sKeyInfo.aSortOrder==0\sin\sperformance-critical\sloops. -D 2012-09-17T17:16:53.958 +C Remove\san\sunnecessary\sparameter\sfrom\ssqlite3Utf8Read()\sresulting\sin\sa\sslight\nperformance\sincrease. +D 2012-09-17T18:56:32.167 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/delete.c 335f36750dc6ac88d580aa36a6487459be9889de F src/expr.c 70ded09d6ac529718aec57589ddb378c23153693 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c c82a04e7a92bb728f9ab972b76590403283be2af -F src/func.c b4e88b92838fdab8e0088cc8411c06664b4dcf55 +F src/func.c cbb90dc84b22eea25caf39528d342279e61b8898 F src/global.c 4cfdca5cb0edd33c4d021baec4ede958cb2c793b F src/hash.c a4031441741932da9e7a65bee2b36b5d0e81c073 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -179,7 +179,7 @@ F src/shell.c 87953c5d9c73d9494db97d1607e2e2280418f261 F src/sqlite.h.in d1071b0fc6de9a0d11392bc01305803122c3ec61 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 0423f0a673e7365827584e86dfbab8c33cf32cf8 +F src/sqliteInt.h 3f2ed42529ad54561e6c8d565afbfc9bca27da9d F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -233,7 +233,7 @@ F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/tokenize.c 1e86210d3976717a19238ea7b047fac481fe8c12 F src/trigger.c 3f258307040173aff383eb23fb74c44fe829078c F src/update.c 28d2d098b43a2c70dae399896ea8a02f622410ef -F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 +F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd F src/vdbe.c fd82787f9fb5bfb48dea822d41f28c2a73c25e2e @@ -1013,7 +1013,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P ad298f52efd0ff123a1a4d6a0fa16fbd4c6b6dad -R 399ab3eadb581c96415fb9d89f0fbcd1 +P 45793f0b844fee7445bc9269b403f89a58f77150 +R 8cd942fbb7e8235e37ae22bd18b6fe8b U drh -Z 939733a13ef406dcc12020fe5915f839 +Z af8c124e8114c6e290ead5d3153e615a diff --git a/manifest.uuid b/manifest.uuid index ddfbcb8578..0019e1e823 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -45793f0b844fee7445bc9269b403f89a58f77150 \ No newline at end of file +8b962c94a2f829f71efdd0ca770469b02feea3e1 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 9d81d0c741..cc74a4ddda 100644 --- a/src/func.c +++ b/src/func.c @@ -493,7 +493,7 @@ struct compareInfo { ** whereas only characters less than 0x80 do in ASCII. */ #if defined(SQLITE_EBCDIC) -# define sqlite3Utf8Read(A,C) (*(A++)) +# define sqlite3Utf8Read(A) (*((*A)++)) # define GlogUpperToLower(A) A = sqlite3UpperToLower[A] #else # define GlogUpperToLower(A) if( !((A)&~0x7f) ){ A = sqlite3UpperToLower[A]; } @@ -550,18 +550,18 @@ static int patternCompare( u8 noCase = pInfo->noCase; int prevEscape = 0; /* True if the previous character was 'escape' */ - while( (c = sqlite3Utf8Read(zPattern,&zPattern))!=0 ){ - if( !prevEscape && c==matchAll ){ - while( (c=sqlite3Utf8Read(zPattern,&zPattern)) == matchAll + while( (c = sqlite3Utf8Read(&zPattern))!=0 ){ + if( c==matchAll && !prevEscape ){ + while( (c=sqlite3Utf8Read(&zPattern)) == matchAll || c == matchOne ){ - if( c==matchOne && sqlite3Utf8Read(zString, &zString)==0 ){ + if( c==matchOne && sqlite3Utf8Read(&zString)==0 ){ return 0; } } if( c==0 ){ return 1; }else if( c==esc ){ - c = sqlite3Utf8Read(zPattern, &zPattern); + c = sqlite3Utf8Read(&zPattern); if( c==0 ){ return 0; } @@ -573,25 +573,25 @@ static int patternCompare( } return *zString!=0; } - while( (c2 = sqlite3Utf8Read(zString,&zString))!=0 ){ + while( (c2 = sqlite3Utf8Read(&zString))!=0 ){ if( noCase ){ GlogUpperToLower(c2); GlogUpperToLower(c); while( c2 != 0 && c2 != c ){ - c2 = sqlite3Utf8Read(zString, &zString); + c2 = sqlite3Utf8Read(&zString); GlogUpperToLower(c2); } }else{ while( c2 != 0 && c2 != c ){ - c2 = sqlite3Utf8Read(zString, &zString); + c2 = sqlite3Utf8Read(&zString); } } if( c2==0 ) return 0; if( patternCompare(zPattern,zString,pInfo,esc) ) return 1; } return 0; - }else if( !prevEscape && c==matchOne ){ - if( sqlite3Utf8Read(zString, &zString)==0 ){ + }else if( c==matchOne && !prevEscape ){ + if( sqlite3Utf8Read(&zString)==0 ){ return 0; } }else if( c==matchSet ){ @@ -599,20 +599,20 @@ static int patternCompare( assert( esc==0 ); /* This only occurs for GLOB, not LIKE */ seen = 0; invert = 0; - c = sqlite3Utf8Read(zString, &zString); + c = sqlite3Utf8Read(&zString); if( c==0 ) return 0; - c2 = sqlite3Utf8Read(zPattern, &zPattern); + c2 = sqlite3Utf8Read(&zPattern); if( c2=='^' ){ invert = 1; - c2 = sqlite3Utf8Read(zPattern, &zPattern); + c2 = sqlite3Utf8Read(&zPattern); } if( c2==']' ){ if( c==']' ) seen = 1; - c2 = sqlite3Utf8Read(zPattern, &zPattern); + c2 = sqlite3Utf8Read(&zPattern); } while( c2 && c2!=']' ){ if( c2=='-' && zPattern[0]!=']' && zPattern[0]!=0 && prior_c>0 ){ - c2 = sqlite3Utf8Read(zPattern, &zPattern); + c2 = sqlite3Utf8Read(&zPattern); if( c>=prior_c && c<=c2 ) seen = 1; prior_c = 0; }else{ @@ -621,7 +621,7 @@ static int patternCompare( } prior_c = c2; } - c2 = sqlite3Utf8Read(zPattern, &zPattern); + c2 = sqlite3Utf8Read(&zPattern); } if( c2==0 || (seen ^ invert)==0 ){ return 0; @@ -629,7 +629,7 @@ static int patternCompare( }else if( esc==c && !prevEscape ){ prevEscape = 1; }else{ - c2 = sqlite3Utf8Read(zString, &zString); + c2 = sqlite3Utf8Read(&zString); if( noCase ){ GlogUpperToLower(c); GlogUpperToLower(c2); @@ -701,7 +701,7 @@ static void likeFunc( "ESCAPE expression must be a single character", -1); return; } - escape = sqlite3Utf8Read(zEsc, &zEsc); + escape = sqlite3Utf8Read(&zEsc); } if( zA && zB ){ struct compareInfo *pInfo = sqlite3_user_data(context); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6f6bfdb148..ccd12451ed 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2956,7 +2956,7 @@ int sqlite3GetInt32(const char *, int*); int sqlite3Atoi(const char*); int sqlite3Utf16ByteLen(const void *pData, int nChar); int sqlite3Utf8CharLen(const char *pData, int nByte); -u32 sqlite3Utf8Read(const u8*, const u8**); +u32 sqlite3Utf8Read(const u8**); /* ** Routines to read and write variable-length integers. These used to diff --git a/src/utf.c b/src/utf.c index e94815b5ab..6d5b1bfe40 100644 --- a/src/utf.c +++ b/src/utf.c @@ -164,25 +164,23 @@ static const unsigned char sqlite3Utf8Trans1[] = { || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \ } u32 sqlite3Utf8Read( - const unsigned char *zIn, /* First byte of UTF-8 character */ - const unsigned char **pzNext /* Write first byte past UTF-8 char here */ + const unsigned char **pz /* Pointer to string from which to read char */ ){ unsigned int c; /* Same as READ_UTF8() above but without the zTerm parameter. ** For this routine, we assume the UTF8 string is always zero-terminated. */ - c = *(zIn++); + c = *((*pz)++); if( c>=0xc0 ){ c = sqlite3Utf8Trans1[c-0xc0]; - while( (*zIn & 0xc0)==0x80 ){ - c = (c<<6) + (0x3f & *(zIn++)); + while( (*(*pz) & 0xc0)==0x80 ){ + c = (c<<6) + (0x3f & *((*pz)++)); } if( c<0x80 || (c&0xFFFFF800)==0xD800 || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } } - *pzNext = zIn; return c; } @@ -283,7 +281,6 @@ int sqlite3VdbeMemTranslate(Mem *pMem, u8 desiredEnc){ if( desiredEnc==SQLITE_UTF16LE ){ /* UTF-8 -> UTF-16 Little-endian */ while( zIn UTF-16 Big-endian */ while( zIn0 && n<=4 ); z[0] = 0; z = zBuf; - c = sqlite3Utf8Read(z, (const u8**)&z); + c = sqlite3Utf8Read((const u8**)&z); t = i; if( i>=0xD800 && i<=0xDFFF ) t = 0xFFFD; if( (i&0xFFFFFFFE)==0xFFFE ) t = 0xFFFD; From f4af1089ab1e8f9cb0ef4f9c69f445253510d8e0 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 17 Sep 2012 19:12:39 +0000 Subject: [PATCH 4/4] Remove obsolete bits from the bitvector that defines disabled optimizations in the SQLITE_TESTCTRL_OPTIMIZATIONS verb of sqlite3_test_control(). FossilOrigin-Name: 4c21ee2d26466f83dec525153e2b1506bd956701 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 17 +++++++---------- src/test1.c | 4 +--- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 92fce0dba0..423fd99e01 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\san\sunnecessary\sparameter\sfrom\ssqlite3Utf8Read()\sresulting\sin\sa\sslight\nperformance\sincrease. -D 2012-09-17T18:56:32.167 +C Remove\sobsolete\sbits\sfrom\sthe\sbitvector\sthat\sdefines\sdisabled\soptimizations\nin\sthe\sSQLITE_TESTCTRL_OPTIMIZATIONS\sverb\sof\ssqlite3_test_control(). +D 2012-09-17T19:12:39.992 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5f4f26109f9d80829122e0e09f9cda008fa065fb F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -179,12 +179,12 @@ F src/shell.c 87953c5d9c73d9494db97d1607e2e2280418f261 F src/sqlite.h.in d1071b0fc6de9a0d11392bc01305803122c3ec61 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 3f2ed42529ad54561e6c8d565afbfc9bca27da9d +F src/sqliteInt.h 1228a3d21694dc08e019735b1a5634e5764d11ea F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e F src/tclsqlite.c e4de2458b3ef38fdd0498bc4e5ea5367a241b0f3 -F src/test1.c 3d70f7c5987f186884cfebbfa7151a7d3d67d86e +F src/test1.c 1ad391d930ff94404768f0ca3c08936f74544fa2 F src/test2.c 4178056dd1e7d70f954ad8a1e3edb71a2a784daf F src/test3.c 3c3c2407fa6ec7a19e24ae23f7cb439d0275a60d F src/test4.c bf9fa9bece01de08e6f5e02314e4af5c13590dfa @@ -1013,7 +1013,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 45793f0b844fee7445bc9269b403f89a58f77150 -R 8cd942fbb7e8235e37ae22bd18b6fe8b +P 8b962c94a2f829f71efdd0ca770469b02feea3e1 +R 67168a23b15c492a24fe7dbe4ad81c6a U drh -Z af8c124e8114c6e290ead5d3153e615a +Z 95f03cf63c4263171e5518be35ff05c6 diff --git a/manifest.uuid b/manifest.uuid index 0019e1e823..d1f3d5acfc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b962c94a2f829f71efdd0ca770469b02feea3e1 \ No newline at end of file +4c21ee2d26466f83dec525153e2b1506bd956701 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index ccd12451ed..b0135f44c9 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -962,16 +962,13 @@ struct sqlite3 { ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. ** These must be the low-order bits of the flags field. */ -#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ -#define SQLITE_ColumnCache 0x02 /* Disable the column cache */ -#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ -#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ -#define SQLITE_IndexCover 0x10 /* Disable index covering table */ -#define SQLITE_GroupByOrder 0x20 /* Disable GROUPBY cover of ORDERBY */ -#define SQLITE_FactorOutConst 0x40 /* Disable factoring out constants */ -#define SQLITE_IdxRealAsInt 0x80 /* Store REAL as INT in indices */ -#define SQLITE_DistinctOpt 0x80 /* DISTINCT using indexes */ -#define SQLITE_OptMask 0xff /* Mask of all disablable opts */ +#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ +#define SQLITE_ColumnCache 0x02 /* Disable the column cache */ +#define SQLITE_GroupByOrder 0x04 /* Disable GROUPBY cover of ORDERBY */ +#define SQLITE_FactorOutConst 0x08 /* Disable factoring out constants */ +#define SQLITE_IdxRealAsInt 0x10 /* Store REAL as INT in indices */ +#define SQLITE_DistinctOpt 0x20 /* DISTINCT using indexes */ +#define SQLITE_OptMask 0xff /* Mask of all disablable opts */ /* ** Possible values for the sqlite.magic field. diff --git a/src/test1.c b/src/test1.c index c3dac06212..55e2df5534 100644 --- a/src/test1.c +++ b/src/test1.c @@ -5936,12 +5936,10 @@ static int optimization_control( { "all", SQLITE_OptMask }, { "query-flattener", SQLITE_QueryFlattener }, { "column-cache", SQLITE_ColumnCache }, - { "index-sort", SQLITE_IndexSort }, - { "index-search", SQLITE_IndexSearch }, - { "index-cover", SQLITE_IndexCover }, { "groupby-order", SQLITE_GroupByOrder }, { "factor-constants", SQLITE_FactorOutConst }, { "real-as-int", SQLITE_IdxRealAsInt }, + { "distinct-opt", SQLITE_DistinctOpt }, }; if( objc!=4 ){