diff options
author | drh <drh@noemail.net> | 2018-02-20 22:20:57 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2018-02-20 22:20:57 +0000 |
commit | 2e178d7321265e21fcec226345267d57a61560ca (patch) | |
tree | 26692f1d95426003db01cedf07466b0802b020f0 /src | |
parent | 7436f1e491c7df4a438a1b9d73f32243362224a0 (diff) | |
download | sqlite-2e178d7321265e21fcec226345267d57a61560ca.tar.gz sqlite-2e178d7321265e21fcec226345267d57a61560ca.zip |
Make the walIndexPage() routine about 3x faster by factoring out the seldom
used reallocation logic into a separate subroutine.
FossilOrigin-Name: e2b107141cd97bd4ab240748a9ce43fc2ec950ea74610697a4a7a3d7a6441e6b
Diffstat (limited to 'src')
-rw-r--r-- | src/wal.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -554,7 +554,11 @@ struct WalIterator { ** page and SQLITE_OK is returned. If an error (an OOM or VFS error) occurs, ** then an SQLite error code is returned and *ppPage is set to 0. */ -static int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){ +static SQLITE_NOINLINE int walIndexPageRealloc( + Wal *pWal, /* The WAL context */ + int iPage, /* The page we seek */ + volatile u32 **ppPage /* Write the page pointer here */ +){ int rc = SQLITE_OK; /* Enlarge the pWal->apWiData[] array if required */ @@ -596,6 +600,16 @@ static int walIndexPage(Wal *pWal, int iPage, volatile u32 **ppPage){ assert( iPage==0 || *ppPage || rc!=SQLITE_OK ); return rc; } +static int walIndexPage( + Wal *pWal, /* The WAL context */ + int iPage, /* The page we seek */ + volatile u32 **ppPage /* Write the page pointer here */ +){ + if( pWal->nWiData<=iPage || (*ppPage = pWal->apWiData[iPage])==0 ){ + return walIndexPageRealloc(pWal, iPage, ppPage); + } + return SQLITE_OK; +} /* ** Return a pointer to the WalCkptInfo structure in the wal-index. |