mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Performance improvements in btreeParseCell() by inlining the varint decoder.
FossilOrigin-Name: faab0ed928074f3ec7c25e1a2058414fbd9b013c
This commit is contained in:
43
src/btree.c
43
src/btree.c
@@ -1054,6 +1054,7 @@ static void btreeParseCellPtr(
|
||||
){
|
||||
u8 *pIter; /* For scanning through pCell */
|
||||
u32 nPayload; /* Number of bytes of cell payload */
|
||||
u64 iKey; /* Extracted Key value */
|
||||
|
||||
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
|
||||
assert( pPage->leaf==0 || pPage->leaf==1 );
|
||||
@@ -1061,8 +1062,46 @@ static void btreeParseCellPtr(
|
||||
assert( pPage->noPayload==0 );
|
||||
assert( pPage->intKeyLeaf );
|
||||
assert( pPage->childPtrSize==0 );
|
||||
pIter = pCell + getVarint32(pCell, nPayload);
|
||||
pIter += getVarint(pIter, (u64*)&pInfo->nKey);
|
||||
pIter = pCell;
|
||||
|
||||
/* The next block of code is equivalent to:
|
||||
**
|
||||
** pIter += getVarint32(pIter, nPayload);
|
||||
**
|
||||
** The code is inlined to avoid a function call.
|
||||
*/
|
||||
nPayload = *pIter;
|
||||
if( nPayload>=0x80 ){
|
||||
u8 *pEnd = &pIter[9];
|
||||
nPayload &= 0x7f;
|
||||
do{
|
||||
nPayload = (nPayload<<7) | (*++pIter & 0x7f);
|
||||
}while( (*pIter)>=0x80 && pIter<pEnd );
|
||||
}
|
||||
pIter++;
|
||||
|
||||
/* The next block of code is equivalent to:
|
||||
**
|
||||
** pIter += getVarint(pIter, (u64*)&pInfo->nKey);
|
||||
**
|
||||
** The code is inlined to avoid a function call.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
pIter++;
|
||||
|
||||
pInfo->nKey = *(i64*)&iKey;
|
||||
pInfo->nPayload = nPayload;
|
||||
pInfo->pPayload = pIter;
|
||||
testcase( nPayload==pPage->maxLocal );
|
||||
|
Reference in New Issue
Block a user