aboutsummaryrefslogtreecommitdiff
path: root/src/rowset.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2016-04-28 18:53:08 +0000
committerdrh <drh@noemail.net>2016-04-28 18:53:08 +0000
commitcb6d66becc06dd0ad293779e02b8b9b25dfe3301 (patch)
tree20d322c7bdc63033585889c7d8f0f0d0de478a5e /src/rowset.c
parent75ab50ce8ff0821bae0989a86f037024fd6a8711 (diff)
downloadsqlite-cb6d66becc06dd0ad293779e02b8b9b25dfe3301.tar.gz
sqlite-cb6d66becc06dd0ad293779e02b8b9b25dfe3301.zip
Rearrange some code in the RowSet logic for clarity of presentation, while
adding an /*OPTIMIZATION-IF-TRUE*/ comment. It should operate identically. FossilOrigin-Name: 5748e64376c1c2be5154a632d1527cfebbb9ec74
Diffstat (limited to 'src/rowset.c')
-rw-r--r--src/rowset.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/rowset.c b/src/rowset.c
index c2e73ed72..65fcdb231 100644
--- a/src/rowset.c
+++ b/src/rowset.c
@@ -338,20 +338,23 @@ static struct RowSetEntry *rowSetNDeepTree(
if( *ppList==0 ){
return 0;
}
- if( iDepth==1 ){
+ if( iDepth>1 ){ /*OPTIMIZATION-IF-TRUE*/
+ /* This branch cases a *balanced* tree to be generated. A valid tree
+ ** is still generated without this branch, but it is wildly unbalanced
+ ** and inefficient. */
+ pLeft = rowSetNDeepTree(ppList, iDepth-1);
+ p = *ppList;
+ if( p==0 ){
+ return pLeft;
+ }
+ p->pLeft = pLeft;
+ *ppList = p->pRight;
+ p->pRight = rowSetNDeepTree(ppList, iDepth-1);
+ }else{
p = *ppList;
*ppList = p->pRight;
p->pLeft = p->pRight = 0;
- return p;
- }
- pLeft = rowSetNDeepTree(ppList, iDepth-1);
- p = *ppList;
- if( p==0 ){
- return pLeft;
}
- p->pLeft = pLeft;
- *ppList = p->pRight;
- p->pRight = rowSetNDeepTree(ppList, iDepth-1);
return p;
}