1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Optimizations to link list merge sort code in vdbesort.c, pcache.c, and

rowset.c.  Resulting binaries are 10 bytes smaller and use 0.03% fewer CPU
cycles.

FossilOrigin-Name: 9033afbb31b28a8ad6856ac1f773d8e83bc9ec1c
This commit is contained in:
drh
2016-05-20 14:54:54 +00:00
parent 1524c672e9
commit b982bfea37
5 changed files with 55 additions and 47 deletions

View File

@@ -692,24 +692,26 @@ void sqlite3PcacheClear(PCache *pCache){
static PgHdr *pcacheMergeDirtyList(PgHdr *pA, PgHdr *pB){
PgHdr result, *pTail;
pTail = &result;
while( pA && pB ){
assert( pA!=0 && pB!=0 );
for(;;){
if( pA->pgno<pB->pgno ){
pTail->pDirty = pA;
pTail = pA;
pA = pA->pDirty;
if( pA==0 ){
pTail->pDirty = pB;
break;
}
}else{
pTail->pDirty = pB;
pTail = pB;
pB = pB->pDirty;
if( pB==0 ){
pTail->pDirty = pA;
break;
}
}
}
if( pA ){
pTail->pDirty = pA;
}else if( pB ){
pTail->pDirty = pB;
}else{
pTail->pDirty = 0;
}
return result.pDirty;
}
@@ -750,7 +752,8 @@ static PgHdr *pcacheSortDirtyList(PgHdr *pIn){
}
p = a[0];
for(i=1; i<N_SORT_BUCKET; i++){
p = pcacheMergeDirtyList(p, a[i]);
if( a[i]==0 ) continue;
p = p ? pcacheMergeDirtyList(p, a[i]) : a[i];
}
return p;
}