Simplify the math slightly, and reduce by one the number of loop iterations,

for the loop in balance_nonroot() that moves cells between pages.

FossilOrigin-Name: 2e838db82e533598b3cb00011c04fc0d5a896895
This commit is contained in:
drh 2014-10-31 12:22:00 +00:00
parent 9c0153457a
commit bec021b9fc
3 changed files with 11 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Add\sthe\s"varint.c"\sutility\sprogram\sin\sthe\stool\sdirectory.
D 2014-10-31T10:31:59.052
C Simplify\sthe\smath\sslightly,\sand\sreduce\sby\sone\sthe\snumber\sof\sloop\siterations,\nfor\sthe\sloop\sin\sbalance_nonroot()\sthat\smoves\scells\sbetween\spages.
D 2014-10-31T12:22:00.360
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -172,7 +172,7 @@ F src/auth.c b56c78ebe40a2110fd361379f7e8162d23f92240
F src/backup.c 7f841396adfd47507ff670a471162d2bfcda3136
F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb
F src/btmutex.c 49ca66250c7dfa844a4d4cb8272b87420d27d3a5
F src/btree.c 7031b8cec28b4ba853090da021c6c456952f1f92
F src/btree.c 0f294d5e1eca7a912037d1992c904e28959a5aa5
F src/btree.h a79aa6a71e7f1055f01052b7f821bd1c2dce95c8
F src/btreeInt.h 026d0129724e8f265fdc60d44ec240cf5a4e6179
F src/build.c 67bb05b1077e0cdaccb2e36bfcbe7a5df9ed31e8
@ -1210,7 +1210,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 9fc7c88e3f5221883aa6eafbf8af3be94db0c299
R 932c8189456e662bc00860a65a53ebcf
P ea5d56be5fe14934e4dbe9c17d46b058f487a231
R 5dd41c1bf29a3c6eca71e97060df99dc
U drh
Z 653e5ed37198e17f610045be3bfdae23
Z 53accc48044e0d3a03ff14711aee89d8

View File

@ -1 +1 @@
ea5d56be5fe14934e4dbe9c17d46b058f487a231
2e838db82e533598b3cb00011c04fc0d5a896895

View File

@ -7036,8 +7036,10 @@ static int balance_nonroot(
**
** If neither of the above apply, the page is safe to update.
*/
for(i=0; i<nNew*2; i++){
int iPg = (i>=nNew ? i-nNew : nNew-1-i);
for(i=1-nNew; i<nNew; i++){
int iPg = i<0 ? -i : i;
/* iPg takes values from nNew-1 down to 0 then back up to nNew-1 again */
assert( iPg>=0 && iPg<nNew );
if( abDone[iPg]==0
&& (iPg==0 || cntOld[iPg-1]>=cntNew[iPg-1] || abDone[iPg-1])
&& (cntNew[iPg]>=cntOld[iPg] || abDone[iPg+1])