/ Check-in [5748e643]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Rearrange some code in the RowSet logic for clarity of presentation, while adding an /*OPTIMIZATION-IF-TRUE*/ comment. It should operate identically.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5748e64376c1c2be5154a632d1527cfebbb9ec74
User & Date: drh 2016-04-28 18:53:08
Context
2016-04-28
19:23
Fix typo in comment. No changes to code. check-in: 9f6f17b5 user: mistachkin tags: trunk
18:53
Rearrange some code in the RowSet logic for clarity of presentation, while adding an /*OPTIMIZATION-IF-TRUE*/ comment. It should operate identically. check-in: 5748e643 user: drh tags: trunk
14:15
Use comments to mark several branches as optimizations. No changes to code. check-in: 33e62747 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/rowset.c.

   334    334     int iDepth
   335    335   ){
   336    336     struct RowSetEntry *p;         /* Root of the new tree */
   337    337     struct RowSetEntry *pLeft;     /* Left subtree */
   338    338     if( *ppList==0 ){
   339    339       return 0;
   340    340     }
   341         -  if( iDepth==1 ){
          341  +  if( iDepth>1 ){   /*OPTIMIZATION-IF-TRUE*/
          342  +    /* This branch cases a *balanced* tree to be generated.  A valid tree
          343  +    ** is still generated without this branch, but it is wildly unbalanced
          344  +    ** and inefficient. */
          345  +    pLeft = rowSetNDeepTree(ppList, iDepth-1);
          346  +    p = *ppList;
          347  +    if( p==0 ){
          348  +      return pLeft;
          349  +    }
          350  +    p->pLeft = pLeft;
          351  +    *ppList = p->pRight;
          352  +    p->pRight = rowSetNDeepTree(ppList, iDepth-1);
          353  +  }else{
   342    354       p = *ppList;
   343    355       *ppList = p->pRight;
   344    356       p->pLeft = p->pRight = 0;
   345         -    return p;
   346    357     }
   347         -  pLeft = rowSetNDeepTree(ppList, iDepth-1);
   348         -  p = *ppList;
   349         -  if( p==0 ){
   350         -    return pLeft;
   351         -  }
   352         -  p->pLeft = pLeft;
   353         -  *ppList = p->pRight;
   354         -  p->pRight = rowSetNDeepTree(ppList, iDepth-1);
   355    358     return p;
   356    359   }
   357    360   
   358    361   /*
   359    362   ** Convert a sorted list of elements into a binary tree. Make the tree
   360    363   ** as deep as it needs to be in order to contain the entire list.
   361    364   */