]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Performance optimization to the moveToRoot() subroutine in btree.c.
authordrh <drh@noemail.net>
Fri, 6 Dec 2013 23:25:27 +0000 (23:25 +0000)
committerdrh <drh@noemail.net>
Fri, 6 Dec 2013 23:25:27 +0000 (23:25 +0000)
FossilOrigin-Name: b5842a70f8e26456a8f0d39539bc266f097480a4

manifest
manifest.uuid
src/btree.c

index af9d22779ad177bde50163a1e3d3bf3828f205f6..029d04e99437389d49fbca451cb6a4f12a23a6cb 100644 (file)
--- a/manifest
+++ b/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
index cff17acb92ae6db7b9c0d9a360c0bfffaf434989..5fac78a151727765267d8eb9309dd86a42036d98 100644 (file)
@@ -1 +1 @@
-c5a3a1af3c7bd34886e944a1fef2f6340ded24a0
\ No newline at end of file
+b5842a70f8e26456a8f0d39539bc266f097480a4
\ No newline at end of file
index e93eeffb360fb147a2a7d0a59b01b397aee28424..a0b6c6ba244a27b754411653d330ec453f3f819f 100644 (file)
@@ -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;
 }