aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordan <dan@noemail.net>2016-05-11 20:03:23 +0000
committerdan <dan@noemail.net>2016-05-11 20:03:23 +0000
commit401907e3ff7616e85469752102c52f4bdaf7d73c (patch)
treefc97b9b10e886cfb1d9da2a6a4f1dec1475a124f /src
parentb2ef900ade31284cbd710bf2fe2c4a88400eed6a (diff)
downloadsqlite-401907e3ff7616e85469752102c52f4bdaf7d73c.tar.gz
sqlite-401907e3ff7616e85469752102c52f4bdaf7d73c.zip
Remove a redundant condition from pcache.c. Add an OPTIMIZATION-IF-TRUE comment to another condition that requires it.
FossilOrigin-Name: 3bfd2621d13b4f842f3af6d35519653f4eb8cad7
Diffstat (limited to 'src')
-rw-r--r--src/pcache.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/pcache.c b/src/pcache.c
index 54b4044a0..4051bee00 100644
--- a/src/pcache.c
+++ b/src/pcache.c
@@ -94,10 +94,15 @@ static void pcacheManageDirtyList(PgHdr *pPage, u8 addRemove){
if( pPage->pDirtyPrev ){
pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext;
}else{
+ /* If there are now no dirty pages in the cache, set eCreate to 2.
+ ** This is an optimization that allows sqlite3PcacheFetch() to skip
+ ** searching for a dirty page to eject from the cache when it might
+ ** otherwise have to. */
assert( pPage==p->pDirty );
p->pDirty = pPage->pDirtyNext;
- if( p->pDirty==0 && p->bPurgeable ){
- assert( p->eCreate==1 );
+ assert( p->bPurgeable || p->eCreate==2 );
+ if( p->pDirty==0 ){ /*OPTIMIZATION-IF-TRUE*/
+ assert( p->bPurgeable==0 || p->eCreate==1 );
p->eCreate = 2;
}
}
@@ -266,6 +271,7 @@ sqlite3_pcache_page *sqlite3PcacheFetch(
assert( pCache->pCache!=0 );
assert( createFlag==3 || createFlag==0 );
assert( pgno>0 );
+ assert( pCache->eCreate==((pCache->bPurgeable && pCache->pDirty) ? 1 : 2) );
/* eCreate defines what to do if the page does not exist.
** 0 Do not allocate a new page. (createFlag==0)