]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplifications and performance improvements in insertCell().
authordrh <drh@noemail.net>
Thu, 25 Jun 2015 19:53:48 +0000 (19:53 +0000)
committerdrh <drh@noemail.net>
Thu, 25 Jun 2015 19:53:48 +0000 (19:53 +0000)
FossilOrigin-Name: 7d02e6c992ef92e1f77ebc13889e17c028454b06

manifest
manifest.uuid
src/btree.c

index 848f3d66c676735954daa15d0438a28df5958418..f42ebf288a8df907e0ace41bc7e189a4d0699852 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C More\ssimplifications\sand\sperformance\simprovements\sto\scell\sallocation\nlogic\sassociated\swith\sallocateSpace().
-D 2015-06-25T18:36:13.826
+C Simplifications\sand\sperformance\simprovements\sin\sinsertCell().
+D 2015-06-25T19:53:48.178
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 1063c58075b7400d93326b0eb332b48a54f53025
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -192,7 +192,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
 F src/backup.c ff743689c4d6c5cb55ad42ed9d174b2b3e71f1e3
 F src/bitvec.c 5eb7958c3bf65210211cbcfc44eff86d0ded7c9d
 F src/btmutex.c 45a968cc85afed9b5e6cf55bf1f42f8d18107f79
-F src/btree.c 960a641306010ed25690af8e05d599fe4b9a005d
+F src/btree.c 40e98c10725c2cec5429068e21c17924f4bf06cc
 F src/btree.h 969adc948e89e449220ff0ff724c94bb2a52e9f1
 F src/btreeInt.h fdd1aff02fb2a63812bd95716e7f579fc3759107
 F src/build.c b3f15255d5b16e42dafeaa638fd4f8a47c94ed70
@@ -1286,7 +1286,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P d67b0ed1054cbb7ea2cdd74720d4d6e0227cec14
-R 4a51cc2794802bb6f018a7f1798d3a79
+P 78da0f69cb3289e332018864004f319f2764a5c8
+R 0d165d2d8c01ecd2475fdbe233dfe5e0
 U drh
-Z 2ec930a14eaee4b6a3bd2ab311de6bca
+Z 8a4a8bb2d9c667bdbc4293aaa6065234
index 6e77614794bfababa7415039ed499a11d1aa1bb6..e18ea8d4d08ecc08f8503db3886085dc0c43bbd1 100644 (file)
@@ -1 +1 @@
-78da0f69cb3289e332018864004f319f2764a5c8
\ No newline at end of file
+7d02e6c992ef92e1f77ebc13889e17c028454b06
\ No newline at end of file
index 9dbdab9b74c07fd8e6fcf5cdf73b05f71e7e1fec..5769a236c888432ec96758ddcc62a7cbee4f8a51 100644 (file)
@@ -6197,10 +6197,8 @@ static void insertCell(
 ){
   int idx = 0;      /* Where to write new cell content in data[] */
   int j;            /* Loop counter */
-  int end;          /* First byte past the last cell pointer in data[] */
-  int ins;          /* Index in data[] where new cell pointer is inserted */
-  int cellOffset;   /* Address of first cell pointer in data[] */
   u8 *data;         /* The content of the whole page */
+  u8 *pIns;         /* The point in pPage->aCellIdx[] where no cell inserted */
 
   if( *pRC ) return;
 
@@ -6244,24 +6242,26 @@ static void insertCell(
     }
     assert( sqlite3PagerIswriteable(pPage->pDbPage) );
     data = pPage->aData;
-    cellOffset = pPage->cellOffset;
-    end = cellOffset + 2*pPage->nCell;
-    ins = cellOffset + 2*i;
+    assert( &data[pPage->cellOffset]==pPage->aCellIdx );
     rc = allocateSpace(pPage, sz, &idx);
     if( rc ){ *pRC = rc; return; }
     /* The allocateSpace() routine guarantees the following properties
     ** if it returns successfully */
-    assert( idx >= 0 && (idx >= end+2 || CORRUPT_DB) );
+    assert( idx >= 0 );
+    assert( idx >= pPage->cellOffset+2*pPage->nCell+2 || CORRUPT_DB );
     assert( idx+sz <= (int)pPage->pBt->usableSize );
-    pPage->nCell++;
     pPage->nFree -= (u16)(2 + sz);
     memcpy(&data[idx], pCell, sz);
     if( iChild ){
       put4byte(&data[idx], iChild);
     }
-    memmove(&data[ins+2], &data[ins], end-ins);
-    put2byte(&data[ins], idx);
-    put2byte(&data[pPage->hdrOffset+3], pPage->nCell);
+    pIns = pPage->aCellIdx + i*2;
+    memmove(pIns+2, pIns, 2*(pPage->nCell - i));
+    put2byte(pIns, idx);
+    pPage->nCell++;
+    /* increment the cell count */
+    if( (++data[pPage->hdrOffset+4])==0 ) data[pPage->hdrOffset+3]++;
+    assert( get2byte(&data[pPage->hdrOffset+3])==pPage->nCell );
 #ifndef SQLITE_OMIT_AUTOVACUUM
     if( pPage->pBt->autoVacuum ){
       /* The cell may contain a pointer to an overflow page. If so, write