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
+4 -2
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])