aboutsummaryrefslogtreecommitdiff
path: root/src/btree.c
diff options
context:
space:
mode:
authordrh <>2022-01-02 16:48:00 +0000
committerdrh <>2022-01-02 16:48:00 +0000
commit29bbc2b51f2477a5a45fe1a99cf56b5d7ea0ca82 (patch)
tree047e7a4ecd534828dc1b3981c94b8f92016d1548 /src/btree.c
parent7e17a3abbe7f1b644661c7e5ededd4679dd1b409 (diff)
downloadsqlite-29bbc2b51f2477a5a45fe1a99cf56b5d7ea0ca82.tar.gz
sqlite-29bbc2b51f2477a5a45fe1a99cf56b5d7ea0ca82.zip
Performance optimization in btreeParseCellPtr() by unrolling the loop that
decodes the rowid. FossilOrigin-Name: fef72368a2eef5cb68ffc56e4f01be212d5e3318ebdb56a23ab26e1ef454272e
Diffstat (limited to 'src/btree.c')
-rw-r--r--src/btree.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/btree.c b/src/btree.c
index 4f777f0f7..b99045c41 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -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);
+ }
+ }
+ }
+ }
+ }
}
}
}