aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2014-10-31 12:22:00 +0000
committerdrh <drh@noemail.net>2014-10-31 12:22:00 +0000
commitbec021b9fca398564dd2eccabe10d8af8fa6fc41 (patch)
tree82e5c30c00d56d12454be7adb07edb470271e72d /src
parent9c0153457af66ca84768c08472f7424f7e6711d0 (diff)
downloadsqlite-bec021b9fca398564dd2eccabe10d8af8fa6fc41.tar.gz
sqlite-bec021b9fca398564dd2eccabe10d8af8fa6fc41.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/btree.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/btree.c b/src/btree.c
index f21fce2a5..4176d2c8b 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -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])