mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Very small performance increase and size reduction by removing unnecessary
ALWAYS() macros from the btree balance logic and replacing them with special initialization of CellArray and some assert()s. FossilOrigin-Name: 32b79041d9b6858e4ffade5841898619c7d25d20c4638bf85447a2ca9cc4a3d3
This commit is contained in:
16
src/btree.c
16
src/btree.c
@ -7567,8 +7567,8 @@ static int rebuildPage(
|
||||
if( j>(u32)usableSize ){ j = 0; }
|
||||
memcpy(&pTmp[j], &aData[j], usableSize - j);
|
||||
|
||||
for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i; k++){}
|
||||
assert( k<NB*2 );
|
||||
assert( pCArray->ixNx[NB*2-1]>i );
|
||||
for(k=0; pCArray->ixNx[k]<=i; k++){}
|
||||
pSrcEnd = pCArray->apEnd[k];
|
||||
|
||||
pData = pEnd;
|
||||
@ -7651,8 +7651,8 @@ static int pageInsertArray(
|
||||
u8 *pEnd; /* Maximum extent of cell data */
|
||||
assert( CORRUPT_DB || pPg->hdrOffset==0 ); /* Never called on page 1 */
|
||||
if( iEnd<=iFirst ) return 0;
|
||||
for(k=0; ALWAYS(k<NB*2) && pCArray->ixNx[k]<=i ; k++){}
|
||||
assert( k<NB*2 );
|
||||
assert( pCArray->ixNx[NB*2-1]>i );
|
||||
for(k=0; pCArray->ixNx[k]<=i ; k++){}
|
||||
pEnd = pCArray->apEnd[k];
|
||||
while( 1 /*Exit by break*/ ){
|
||||
int sz, rc;
|
||||
@ -8172,7 +8172,9 @@ static int balance_nonroot(
|
||||
CellArray b; /* Parsed information on cells being balanced */
|
||||
|
||||
memset(abDone, 0, sizeof(abDone));
|
||||
memset(&b, 0, sizeof(b));
|
||||
assert( sizeof(b) - sizeof(b.ixNx) == offsetof(CellArray,ixNx) );
|
||||
memset(&b, 0, sizeof(b)-sizeof(b.ixNx));
|
||||
b.ixNx[NB*2-1] = 0x7fffffff;
|
||||
pBt = pParent->pBt;
|
||||
assert( sqlite3_mutex_held(pBt->mutex) );
|
||||
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
|
||||
@ -8763,8 +8765,8 @@ static int balance_nonroot(
|
||||
iOvflSpace += sz;
|
||||
assert( sz<=pBt->maxLocal+23 );
|
||||
assert( iOvflSpace <= (int)pBt->pageSize );
|
||||
for(k=0; ALWAYS(k<NB*2) && b.ixNx[k]<=j; k++){}
|
||||
assert( k<NB*2 );
|
||||
assert( b.ixNx[NB*2-1]>j );
|
||||
for(k=0; b.ixNx[k]<=j; k++){}
|
||||
pSrcEnd = b.apEnd[k];
|
||||
if( SQLITE_OVERFLOW(pSrcEnd, pCell, pCell+sz) ){
|
||||
rc = SQLITE_CORRUPT_BKPT;
|
||||
|
Reference in New Issue
Block a user