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

Refactor the sqlite3PcacheFetch() routine into three separate routines,

which are significantly faster overall and about 100 bytes smaller in
size as well.

FossilOrigin-Name: bdb6e4978d1a26d5f795262172605184264ede9c
This commit is contained in:
drh
2014-08-27 23:18:01 +00:00
parent a1dc42aa91
commit bc59ac0e26
5 changed files with 155 additions and 80 deletions

View File

@@ -5286,7 +5286,6 @@ int sqlite3PagerAcquire(
if( pPager->errCode!=SQLITE_OK ){
rc = pPager->errCode;
}else{
if( bMmapOk && pagerUseWal(pPager) ){
rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);
if( rc!=SQLITE_OK ) goto pager_acquire_err;
@@ -5301,7 +5300,7 @@ int sqlite3PagerAcquire(
if( rc==SQLITE_OK && pData ){
if( pPager->eState>PAGER_READER ){
(void)sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);
pPg = sqlite3PagerLookup(pPager, pgno);
}
if( pPg==0 ){
rc = pagerAcquireMapPage(pPager, pgno, pData, &pPg);
@@ -5319,7 +5318,16 @@ int sqlite3PagerAcquire(
}
}
rc = sqlite3PcacheFetch(pPager->pPCache, pgno, 3, ppPage);
{
sqlite3_pcache_page *pBase;
pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
if( pBase==0 ){
rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
if( rc!=SQLITE_OK ) goto pager_acquire_err;
}
pPg = *ppPage = sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pBase);
if( pPg==0 ) rc = SQLITE_NOMEM;
}
}
if( rc!=SQLITE_OK ){
@@ -5416,12 +5424,12 @@ pager_acquire_err:
** has ever happened.
*/
DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno){
PgHdr *pPg = 0;
sqlite3_pcache_page *pPage;
assert( pPager!=0 );
assert( pgno!=0 );
assert( pPager->pPCache!=0 );
sqlite3PcacheFetch(pPager->pPCache, pgno, 0, &pPg);
return pPg;
pPage = sqlite3PcacheFetch(pPager->pPCache, pgno, 0);
return sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pPage);
}
/*