/ Check-in [3bfd2621]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove a redundant condition from pcache.c. Add an OPTIMIZATION-IF-TRUE comment to another condition that requires it.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3bfd2621d13b4f842f3af6d35519653f4eb8cad7
User & Date: dan 2016-05-11 20:03:23
Context
2016-05-12
09:48
Add a missing OPTIMIZATION-IF-FALSE comment to pcache.c. check-in: bc202e5b user: dan tags: trunk
2016-05-11
23:54
For in-memory databases, it does not matter if pcache entries are marked "clean" or "writable". Closed-Leaf check-in: ad601c79 user: drh tags: pager-dev
20:03
Remove a redundant condition from pcache.c. Add an OPTIMIZATION-IF-TRUE comment to another condition that requires it. check-in: 3bfd2621 user: dan tags: trunk
15:41
Remove some a small amount of redundant code related to PCache.pSynced from pcache.c. check-in: 9cc8cad7 user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/pcache.c.

    90     90       }else{
    91     91         assert( pPage==p->pDirtyTail );
    92     92         p->pDirtyTail = pPage->pDirtyPrev;
    93     93       }
    94     94       if( pPage->pDirtyPrev ){
    95     95         pPage->pDirtyPrev->pDirtyNext = pPage->pDirtyNext;
    96     96       }else{
           97  +      /* If there are now no dirty pages in the cache, set eCreate to 2. 
           98  +      ** This is an optimization that allows sqlite3PcacheFetch() to skip
           99  +      ** searching for a dirty page to eject from the cache when it might
          100  +      ** otherwise have to.  */
    97    101         assert( pPage==p->pDirty );
    98    102         p->pDirty = pPage->pDirtyNext;
    99         -      if( p->pDirty==0 && p->bPurgeable ){
   100         -        assert( p->eCreate==1 );
          103  +      assert( p->bPurgeable || p->eCreate==2 );
          104  +      if( p->pDirty==0 ){         /*OPTIMIZATION-IF-TRUE*/
          105  +        assert( p->bPurgeable==0 || p->eCreate==1 );
   101    106           p->eCreate = 2;
   102    107         }
   103    108       }
   104    109       pPage->pDirtyNext = 0;
   105    110       pPage->pDirtyPrev = 0;
   106    111     }
   107    112     if( addRemove & PCACHE_DIRTYLIST_ADD ){
................................................................................
   262    267     int eCreate;
   263    268     sqlite3_pcache_page *pRes;
   264    269   
   265    270     assert( pCache!=0 );
   266    271     assert( pCache->pCache!=0 );
   267    272     assert( createFlag==3 || createFlag==0 );
   268    273     assert( pgno>0 );
          274  +  assert( pCache->eCreate==((pCache->bPurgeable && pCache->pDirty) ? 1 : 2) );
   269    275   
   270    276     /* eCreate defines what to do if the page does not exist.
   271    277     **    0     Do not allocate a new page.  (createFlag==0)
   272    278     **    1     Allocate a new page if doing so is inexpensive.
   273    279     **          (createFlag==1 AND bPurgeable AND pDirty)
   274    280     **    2     Allocate a new page even it doing so is difficult.
   275    281     **          (createFlag==1 AND !(bPurgeable AND pDirty)