]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Another optimization to the btree logic. (CVS 811)
authordrh <drh@noemail.net>
Sat, 4 Jan 2003 18:53:27 +0000 (18:53 +0000)
committerdrh <drh@noemail.net>
Sat, 4 Jan 2003 18:53:27 +0000 (18:53 +0000)
FossilOrigin-Name: 03d20673616cae0dca524fd04557798a98fb7069

manifest
manifest.uuid
src/btree.c

index 0798b218f1f94e1383ce4f020903ea89c5572230..e9d4159063270bd3a7e7d6e278e492d98b26935a 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Optimizations\sto\sthe\sBTree\smodule\sfor\sa\smodest\sspeed\simprovement.\s(CVS\s810)
-D 2003-01-04T16:48:09
+C Another\soptimization\sto\sthe\sbtree\slogic.\s(CVS\s811)
+D 2003-01-04T18:53:28
 F Makefile.in 868c17a1ae1c07603d491274cc8f86c04acf2a1e
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -18,7 +18,7 @@ F main.mk 9d13839b9697af332d788fe6e801e68da027cc5c
 F publish.sh e5b83867d14708ed58cec8cba0a4f201e969474d
 F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
 F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
-F src/btree.c 4ed13ad0c695e4fb803d106926c6fdd08a0b4d0f
+F src/btree.c 9ae3232125d54e0f4c73ae88af1f4556e15440e9
 F src/btree.h 17710339f7a8f46e3c7d6d0d4648ef19c584ffda
 F src/build.c 8569ac014609add4b796260d3567a5090b90056d
 F src/delete.c aad9d4051ab46e6f6391ea5f7b8994a7c05bdd15
@@ -152,7 +152,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803
 F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 1ba41bc2afab18cc295d9a45845296b46bfa57e5
-R a4125fbf39c245763f99492b33c9c8e8
+P 39902a70417475225956704a037493515e9b08b9
+R 5307d3e389db7bcbbe208e92a667a5a5
 U drh
-Z df8ce8a4e13ca11e4b128387a80bf533
+Z 5237255ce20b25abc6c29c72daee1d77
index 8a7d2821720cc07d0cf98027265bffa44f041e8d..5a343221c7d25f56d21fdd370e32bceb8fe26181 100644 (file)
@@ -1 +1 @@
-39902a70417475225956704a037493515e9b08b9
\ No newline at end of file
+03d20673616cae0dca524fd04557798a98fb7069
\ No newline at end of file
index cc178c964467db2a5de29ae4ffbce044b76e0c4e..a99f86729dc2409a4fe7b419eb81befa2fa2f698 100644 (file)
@@ -9,7 +9,7 @@
 **    May you share freely, never taking more than you give.
 **
 *************************************************************************
-** $Id: btree.c,v 1.77 2003/01/04 16:48:09 drh Exp $
+** $Id: btree.c,v 1.78 2003/01/04 18:53:28 drh Exp $
 **
 ** This file implements a external (disk-based) database using BTrees.
 ** For a detailed discussion of BTrees, refer to
@@ -2123,7 +2123,6 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
   int cntNew[4];               /* Index in apCell[] of cell after i-th page */
   int szNew[4];                /* Combined size of cells place on i-th page */
   MemPage *extraUnref = 0;     /* A page that needs to be unref-ed */
-  Pgno pgno, swabPgno;         /* Page number */
   Cell *apCell[MX_CELL*3+5];   /* All cells from pages being balanceed */
   int szCell[MX_CELL*3+5];     /* Local size of all cells */
   Cell aTemp[2];               /* Temporary holding area for apDiv[] */
@@ -2198,7 +2197,7 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
     assert( sqlitepager_iswriteable(pChild) );
     copyPage(pChild, pPage);
     pChild->pParent = pPage;
-    pChild->idxParent = pChild->nCell;
+    pChild->idxParent = 0;
     sqlitepager_ref(pPage);
     pChild->isOverfull = 1;
     if( pCur && pCur->pPage==pPage ){
@@ -2221,20 +2220,19 @@ static int balance(Btree *pBt, MemPage *pPage, BtCursor *pCur){
   ** to pPage.  The "idx" variable is the index of that cell.  If pPage
   ** is the rightmost child of pParent then set idx to pParent->nCell 
   */
-  idx = -1;
-  pgno = sqlitepager_pagenumber(pPage);
-  swabPgno = SWAB32(pBt, pgno);
-  for(i=0; i<pParent->nCell; i++){
-    if( pParent->apCell[i]->h.leftChild==swabPgno ){
-      idx = i;
-      break;
+  if( pParent->idxShift ){
+    Pgno pgno, swabPgno;
+    pgno = sqlitepager_pagenumber(pPage);
+    swabPgno = SWAB32(pBt, pgno);
+    for(idx=0; idx<pParent->nCell; idx++){
+      if( pParent->apCell[idx]->h.leftChild==swabPgno ){
+        break;
+      }
     }
+    assert( idx<pParent->nCell || pParent->u.hdr.rightChild==swabPgno );
+  }else{
+    idx = pPage->idxParent;
   }
-  if( idx<0 && pParent->u.hdr.rightChild==swabPgno ){
-    idx = pParent->nCell;
-  }
-  assert( idx>=0 );
-  /* assert( pParent->idxShift || idx==pPage->idxParent ); */
 
   /*
   ** Initialize variables so that it will be safe to jump