Performance optimization to the moveToRoot() subroutine in btree.c.
FossilOrigin-Name: b5842a70f8e26456a8f0d39539bc266f097480a4
This commit is contained in:
parent
b8a9bb4fb9
commit
4e8fe3ff91
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Use\smemcmp()\sinstead\sof\sthe\sBINARY\scollating\sfunction\swhere\spossible,\sfor\na\sperformance\sboost.
|
||||
D 2013-12-06T22:45:31.452
|
||||
C Performance\soptimization\sto\sthe\smoveToRoot()\ssubroutine\sin\sbtree.c.
|
||||
D 2013-12-06T23:25:27.601
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in e1a9b4258bbde53f5636f4e238c65b7e11459e2b
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -166,7 +166,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
|
||||
F src/backup.c 1809a7caa2504233bdddd12f5018422421789537
|
||||
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
|
||||
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
|
||||
F src/btree.c 1c1228bfeff3142c3d30f37f41c62e1e1456a04b
|
||||
F src/btree.c 4037f58ef3f4459d0b9bb1fc1aee1136277d9ba6
|
||||
F src/btree.h a61ddebc78c66795a2b93181321a116746302cc9
|
||||
F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0
|
||||
F src/build.c 9b40580b62916612678bdb69ce0286e39c29a862
|
||||
@ -1145,7 +1145,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
|
||||
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
|
||||
F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
|
||||
F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
|
||||
P 2d62d1131f8bbc4e1f8f7aeaf0d91e3237fe3b7c
|
||||
R 64ecaeb699cffb8c7d50ef92ad2b85dd
|
||||
P c5a3a1af3c7bd34886e944a1fef2f6340ded24a0
|
||||
R 12065e363c2320b45db52efcb2788f0d
|
||||
U drh
|
||||
Z 924fa8368d7b3d9057325dee3400f3cb
|
||||
Z 6564d15f297e6c8ddf25ac421a3f69fc
|
||||
|
@ -1 +1 @@
|
||||
c5a3a1af3c7bd34886e944a1fef2f6340ded24a0
|
||||
b5842a70f8e26456a8f0d39539bc266f097480a4
|
16
src/btree.c
16
src/btree.c
@ -4395,8 +4395,6 @@ static void moveToParent(BtCursor *pCur){
|
||||
static int moveToRoot(BtCursor *pCur){
|
||||
MemPage *pRoot;
|
||||
int rc = SQLITE_OK;
|
||||
Btree *p = pCur->pBtree;
|
||||
BtShared *pBt = p->pBt;
|
||||
|
||||
assert( cursorHoldsMutex(pCur) );
|
||||
assert( CURSOR_INVALID < CURSOR_REQUIRESEEK );
|
||||
@ -4411,16 +4409,12 @@ static int moveToRoot(BtCursor *pCur){
|
||||
}
|
||||
|
||||
if( pCur->iPage>=0 ){
|
||||
int i;
|
||||
for(i=1; i<=pCur->iPage; i++){
|
||||
releasePage(pCur->apPage[i]);
|
||||
}
|
||||
pCur->iPage = 0;
|
||||
while( pCur->iPage ) releasePage(pCur->apPage[pCur->iPage--]);
|
||||
}else if( pCur->pgnoRoot==0 ){
|
||||
pCur->eState = CURSOR_INVALID;
|
||||
return SQLITE_OK;
|
||||
}else{
|
||||
rc = getAndInitPage(pBt, pCur->pgnoRoot, &pCur->apPage[0],
|
||||
rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->apPage[0],
|
||||
pCur->wrFlag==0 ? PAGER_GET_READONLY : 0);
|
||||
if( rc!=SQLITE_OK ){
|
||||
pCur->eState = CURSOR_INVALID;
|
||||
@ -4453,14 +4447,16 @@ static int moveToRoot(BtCursor *pCur){
|
||||
pCur->atLast = 0;
|
||||
pCur->validNKey = 0;
|
||||
|
||||
if( pRoot->nCell==0 && !pRoot->leaf ){
|
||||
if( pRoot->nCell>0 ){
|
||||
pCur->eState = CURSOR_VALID;
|
||||
}else if( !pRoot->leaf ){
|
||||
Pgno subpage;
|
||||
if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;
|
||||
subpage = get4byte(&pRoot->aData[pRoot->hdrOffset+8]);
|
||||
pCur->eState = CURSOR_VALID;
|
||||
rc = moveToChild(pCur, subpage);
|
||||
}else{
|
||||
pCur->eState = ((pRoot->nCell>0)?CURSOR_VALID:CURSOR_INVALID);
|
||||
pCur->eState = CURSOR_INVALID;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user