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

More improvements to sqlite3BtreeMovetoUnpacked() performance.

FossilOrigin-Name: 88680698231b7141401f7166e3aff8dbc6008030
This commit is contained in:
drh
2013-11-25 14:10:15 +00:00
parent ec3e6b10f4
commit d793f44723
3 changed files with 23 additions and 23 deletions

View File

@@ -4662,14 +4662,10 @@ int sqlite3BtreeMovetoUnpacked(
assert( pPage->intKey==(pIdxKey==0) );
lwr = 0;
upr = pPage->nCell-1;
if( biasRight ){
pCur->aiIdx[pCur->iPage] = (u16)(idx = upr);
}else{
pCur->aiIdx[pCur->iPage] = (u16)(idx = (upr+lwr)/2);
}
idx = biasRight ? upr : (upr+lwr)/2;
pCur->aiIdx[pCur->iPage] = (u16)idx;
pCur->info.nSize = 0;
if( pPage->intKey ){
assert( idx==pCur->aiIdx[pCur->iPage] );
for(;;){
i64 nCellKey;
pCell = findCell(pPage, idx) + pPage->childPtrSize;
@@ -4681,6 +4677,7 @@ int sqlite3BtreeMovetoUnpacked(
if( nCellKey==intKey ){
pCur->validNKey = 1;
pCur->info.nKey = nCellKey;
pCur->aiIdx[pCur->iPage] = (u16)idx;
if( !pPage->leaf ){
lwr = idx;
break;
@@ -4690,20 +4687,21 @@ int sqlite3BtreeMovetoUnpacked(
goto moveto_finish;
}
}else if( nCellKey<intKey ){
c = -1;
lwr = idx+1;
}else{
assert( nCellKey>intKey );
c = +1;
upr = idx-1;
}
if( lwr>upr ) break;
pCur->aiIdx[pCur->iPage] = (u16)(idx = (lwr+upr)/2);
if( lwr>upr ){
c = nCellKey<intKey ? -1 : +1;
pCur->aiIdx[pCur->iPage] = (u16)idx;
break;
}
idx = (lwr+upr)/2;
}
}else{
for(;;){
int nCell;
assert( idx==pCur->aiIdx[pCur->iPage] );
pCell = findCell(pPage, idx) + pPage->childPtrSize;
/* The maximum supported page-size is 65536 bytes. This means that
@@ -4745,6 +4743,7 @@ int sqlite3BtreeMovetoUnpacked(
rc = SQLITE_NOMEM;
goto moveto_finish;
}
pCur->aiIdx[pCur->iPage] = (u16)idx;
rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
if( rc ){
sqlite3_free(pCellKey);
@@ -4756,6 +4755,7 @@ int sqlite3BtreeMovetoUnpacked(
if( c==0 ){
*pRes = 0;
rc = SQLITE_OK;
pCur->aiIdx[pCur->iPage] = (u16)idx;
goto moveto_finish;
}
if( c<0 ){
@@ -4763,8 +4763,11 @@ int sqlite3BtreeMovetoUnpacked(
}else{
upr = idx-1;
}
if( lwr>upr ) break;
pCur->aiIdx[pCur->iPage] = (u16)(idx = (lwr+upr)/2);
if( lwr>upr ){
pCur->aiIdx[pCur->iPage] = (u16)idx;
break;
}
idx = (lwr+upr)/2;
}
}
assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );