aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2018-02-20 22:20:57 +0000
committerdrh <drh@noemail.net>2018-02-20 22:20:57 +0000
commit2e178d7321265e21fcec226345267d57a61560ca (patch)
tree26692f1d95426003db01cedf07466b0802b020f0 /src
parent7436f1e491c7df4a438a1b9d73f32243362224a0 (diff)
downloadsqlite-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.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/wal.c b/src/wal.c
index 7b49f3dab..99832dff3 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -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.