1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Factor an "if" out of a loop in balance_nonroot() for about a 1% performance

increase.

FossilOrigin-Name: 1bd72d0c616e20fdb395c72ecd96579090ae26cb
This commit is contained in:
drh
2011-06-03 17:50:49 +00:00
parent 45caededba
commit 68f2a57698
3 changed files with 27 additions and 13 deletions

View File

@@ -857,6 +857,8 @@ static int ptrmapGet(BtShared *pBt, Pgno key, u8 *pEType, Pgno *pPgno){
*/
#define findCell(P,I) \
((P)->aData + ((P)->maskPage & get2byte(&(P)->aData[(P)->cellOffset+2*(I)])))
#define findCellv2(D,M,O,I) (D+(M&get2byte(D+(O+2*(I)))))
/*
** This a more complex version of findCell() that works for
@@ -6016,12 +6018,24 @@ static int balance_nonroot(
memcpy(pOld->aData, apOld[i]->aData, pBt->pageSize);
limit = pOld->nCell+pOld->nOverflow;
for(j=0; j<limit; j++){
assert( nCell<nMaxCells );
apCell[nCell] = findOverflowCell(pOld, j);
szCell[nCell] = cellSizePtr(pOld, apCell[nCell]);
nCell++;
}
if( pOld->nOverflow>0 ){
for(j=0; j<limit; j++){
assert( nCell<nMaxCells );
apCell[nCell] = findOverflowCell(pOld, j);
szCell[nCell] = cellSizePtr(pOld, apCell[nCell]);
nCell++;
}
}else{
u8 *aData = pOld->aData;
u16 maskPage = pOld->maskPage;
u16 cellOffset = pOld->cellOffset;
for(j=0; j<limit; j++){
assert( nCell<nMaxCells );
apCell[nCell] = findCellv2(aData, maskPage, cellOffset, j);
szCell[nCell] = cellSizePtr(pOld, apCell[nCell]);
nCell++;
}
}
if( i<nOld-1 && !leafData){
u16 sz = (u16)szNew[i];
u8 *pTemp;