-C Reimplement\sthe\sfreeSpace()\sroutine\sin\sbtree.c\sso\sthat\sit\sruns\sfaster.
-D 2014-08-20T17:56:27.585
+C A\ssmall\sperformance\simprovement\sin\sfreeSpace()\sby\sspecial-casing\sthe\nrelatively\scommon\scase\sof\san\sempty\sfreelist.
+D 2014-08-20T18:43:44.510
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 5eb79e334a5de69c87740edd56af6527dd219308
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7
-F src/btree.c fe2d11c8c0d99e324614141ad012b37d0601cf59
+F src/btree.c 4195fed5741b4dbcc9831b623aec487258f3e62d
F src/btree.h 4245a349bfe09611d7ff887dbc3a80cee8b7955a
F src/btreeInt.h cf180d86b2e9e418f638d65baa425c4c69c0e0e3
F src/build.c 5abf794fe8a605f2005b422e98a3cedad9b9ef5b
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 7e63089a191f29aefde05e89bb612f3036cfa034
-R cbff1ae81d05ca3b78b420deaaa6083f
+P fe4fd014b42b7b158ca968f1535b5636c67769f6
+R 865eceb09aea170bb70d44b771b85e6e
U drh
-Z d684bbbc1bfe7cdee532398c2232ddf8
+Z 0631afdcc5729e41fc50a75336710200
*/
hdr = pPage->hdrOffset;
iPtr = hdr + 1;
- while( (iFreeBlk = get2byte(&data[iPtr]))>0 && iFreeBlk<iStart ){
- if( iFreeBlk<iPtr+4 ) return SQLITE_CORRUPT_BKPT;
- iPtr = iFreeBlk;
- }
- if( iFreeBlk>iLast ) return SQLITE_CORRUPT_BKPT;
- assert( iFreeBlk>iPtr || iFreeBlk==0 );
-
- /* At this point:
- ** iFreeBlk: First freeblock after iStart, or zero if none
- ** iPtr: The address of a pointer iFreeBlk
- **
- ** Check to see if iFreeBlk should be coalesced onto the end of iStart.
- */
- if( iFreeBlk && iEnd+3>=iFreeBlk ){
- nFrag = iFreeBlk - iEnd;
- if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_BKPT;
- iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);
- iSize = iEnd - iStart;
- iFreeBlk = get2byte(&data[iFreeBlk]);
- }
-
- /* If iPtr is another freeblock (that is, if iPtr is not the freelist pointer
- ** in the page header) then check to see if iStart should be coalesced
- ** onto the end of iPtr.
- */
- if( iPtr>hdr+1 ){
- int iPtrEnd = iPtr + get2byte(&data[iPtr+2]);
- if( iPtrEnd+3>=iStart ){
- if( iPtrEnd>iStart ) return SQLITE_CORRUPT_BKPT;
- nFrag += iStart - iPtrEnd;
- iSize = iEnd - iPtr;
- iStart = iPtr;
+ if( data[iPtr+1]==0 && data[iPtr]==0 ){
+ iFreeBlk = 0; /* Shortcut for the case when the freelist is empty */
+ }else{
+ while( (iFreeBlk = get2byte(&data[iPtr]))>0 && iFreeBlk<iStart ){
+ if( iFreeBlk<iPtr+4 ) return SQLITE_CORRUPT_BKPT;
+ iPtr = iFreeBlk;
}
+ if( iFreeBlk>iLast ) return SQLITE_CORRUPT_BKPT;
+ assert( iFreeBlk>iPtr || iFreeBlk==0 );
+
+ /* At this point:
+ ** iFreeBlk: First freeblock after iStart, or zero if none
+ ** iPtr: The address of a pointer iFreeBlk
+ **
+ ** Check to see if iFreeBlk should be coalesced onto the end of iStart.
+ */
+ if( iFreeBlk && iEnd+3>=iFreeBlk ){
+ nFrag = iFreeBlk - iEnd;
+ if( iEnd>iFreeBlk ) return SQLITE_CORRUPT_BKPT;
+ iEnd = iFreeBlk + get2byte(&data[iFreeBlk+2]);
+ iSize = iEnd - iStart;
+ iFreeBlk = get2byte(&data[iFreeBlk]);
+ }
+
+ /* If iPtr is another freeblock (that is, if iPtr is not the freelist pointer
+ ** in the page header) then check to see if iStart should be coalesced
+ ** onto the end of iPtr.
+ */
+ if( iPtr>hdr+1 ){
+ int iPtrEnd = iPtr + get2byte(&data[iPtr+2]);
+ if( iPtrEnd+3>=iStart ){
+ if( iPtrEnd>iStart ) return SQLITE_CORRUPT_BKPT;
+ nFrag += iStart - iPtrEnd;
+ iSize = iEnd - iPtr;
+ iStart = iPtr;
+ }
+ }
+ if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_BKPT;
+ data[hdr+7] -= nFrag;
}
- if( nFrag>data[hdr+7] ) return SQLITE_CORRUPT_BKPT;
-
- data[hdr+7] -= nFrag;
- if( iPtr==hdr+1 && iStart==get2byte(&data[hdr+5]) ){
+ if( iStart==get2byte(&data[hdr+5]) ){
/* The new freeblock is at the beginning of the cell content area,
** so just extend the cell content area rather than create another
** freelist entry */
+ if( iPtr!=hdr+1 ) return SQLITE_CORRUPT_BKPT;
put2byte(&data[hdr+1], iFreeBlk);
put2byte(&data[hdr+5], iEnd);
}else{