From: drh Date: Fri, 20 Jan 2017 20:43:14 +0000 (+0000) Subject: Minor performance optimization and size reduction to the accessPayload() X-Git-Tag: version-3.17.0~91 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd645530157e1e754cf0fa37c3815a2253d01124;p=thirdparty%2Fsqlite.git Minor performance optimization and size reduction to the accessPayload() routine in btree.c. FossilOrigin-Name: 264e5c10d7144910b3223b64546567fa20e4bc65 --- diff --git a/manifest b/manifest index 5ca437cb49..9780aa2959 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\stypo\sin\sthe\shelp\smessage\sfor\skvtest. -D 2017-01-20T16:47:34.130 +C Minor\sperformance\soptimization\sand\ssize\sreduction\sto\sthe\saccessPayload()\nroutine\sin\sbtree.c. +D 2017-01-20T20:43:14.971 F Makefile.in 41bd4cad981487345c4a84081074bcdb876e4b2e F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc b8ca53350ae545e3562403d5da2a69cec79308da @@ -333,7 +333,7 @@ F src/auth.c 930b376a9c56998557367e6f7f8aaeac82a2a792 F src/backup.c faf17e60b43233c214aae6a8179d24503a61e83b F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 0e9ce2d56159b89b9bc8e197e023ee11e39ff8ca -F src/btree.c 69966fb2c574954cd3216f09407c9a02c52d3bd7 +F src/btree.c e6b8f39d7dd1ad65f1747956de36f2595172a23d F src/btree.h e6d352808956ec163a17f832193a3e198b3fb0ac F src/btreeInt.h 10c4b77c2fb399580babbcc7cf652ac10dba796e F src/build.c 9e799f1edd910dfa8a0bc29bd390d35d310596af @@ -1547,7 +1547,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 90291327fc127671d9847a4a2ce1ed47a408cfc6 -R a902108b38beec2205eaeba771709e26 -U dan -Z 09bc78c7c0c7ebb44e280cf03b306ae8 +P 8971d98f25a4f5fb060db8ed6a4b06f083122a50 +R 6803846831f043d39b9c85f99ff10309 +U drh +Z 62cd4db9c45f8ac36491823fd1143808 diff --git a/manifest.uuid b/manifest.uuid index 4b97c1dc13..6d1f724a7b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8971d98f25a4f5fb060db8ed6a4b06f083122a50 \ No newline at end of file +264e5c10d7144910b3223b64546567fa20e4bc65 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7b56867646..fb05655912 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4523,16 +4523,14 @@ static int accessPayload( pCur->aOverflow, nOvfl*2*sizeof(Pgno) ); if( aNew==0 ){ - rc = SQLITE_NOMEM_BKPT; + return SQLITE_NOMEM_BKPT; }else{ pCur->nOvflAlloc = nOvfl*2; pCur->aOverflow = aNew; } } - if( rc==SQLITE_OK ){ - memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno)); - pCur->curFlags |= BTCF_ValidOvfl; - } + memset(pCur->aOverflow, 0, nOvfl*sizeof(Pgno)); + pCur->curFlags |= BTCF_ValidOvfl; } /* If the overflow page-list cache has been allocated and the @@ -4547,8 +4545,8 @@ static int accessPayload( offset = (offset%ovflSize); } - for( ; rc==SQLITE_OK && amt>0 && nextPage; iIdx++){ - + assert( rc==SQLITE_OK && amt>0 ); + while( nextPage ){ /* If required, populate the overflow page-list cache. */ if( (pCur->curFlags & BTCF_ValidOvfl)!=0 ){ assert( pCur->aOverflow[iIdx]==0 @@ -4637,6 +4635,9 @@ static int accessPayload( amt -= a; pBuf += a; } + if( amt==0 ) break; + if( rc ) break; + iIdx++; } }