1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-05 15:55:57 +03:00

Performance optimization in btreeParseCellPtr() by unrolling the loop that

decodes the rowid.

FossilOrigin-Name: fef72368a2eef5cb68ffc56e4f01be212d5e3318ebdb56a23ab26e1ef454272e
This commit is contained in:
drh
2022-01-02 16:48:00 +00:00
parent 7e17a3abbe
commit 29bbc2b51f
3 changed files with 30 additions and 16 deletions

View File

@@ -1225,18 +1225,32 @@ static void btreeParseCellPtr(
**
** pIter += getVarint(pIter, (u64*)&pInfo->nKey);
**
** The code is inlined to avoid a function call.
** The code is inlined and the loop is unrolled for performance.
** This routine is a high-runner.
*/
iKey = *pIter;
if( iKey>=0x80 ){
u8 *pEnd = &pIter[7];
iKey &= 0x7f;
while(1){
iKey = (iKey<<7) | (*++pIter & 0x7f);
if( (*pIter)<0x80 ) break;
if( pIter>=pEnd ){
iKey = (iKey<<8) | *++pIter;
break;
u8 x;
iKey = ((iKey&0x7f)<<7) | ((x = *++pIter) & 0x7f);
if( x>=0x80 ){
iKey = (iKey<<7) | ((x =*++pIter) & 0x7f);
if( x>=0x80 ){
iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
if( x>=0x80 ){
iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
if( x>=0x80 ){
iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
if( x>=0x80 ){
iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
if( x>=0x80 ){
iKey = (iKey<<7) | ((x = *++pIter) & 0x7f);
if( x>=0x80 ){
iKey = (iKey<<8) | (*++pIter);
}
}
}
}
}
}
}
}