/ Check-in [4854ea9c]
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:Unwind the RTREE dimension loop inside of rtreeCallbackConstraint().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 4854ea9c18e7d8066c90b41568d0fae97b01ea6d
User & Date: drh 2017-02-01 17:08:56
Context
2017-02-01
22:32
Add an option to the MSVC makefile to enable treating warnings as errors. check-in: 6a378c29 user: mistachkin tags: trunk
17:08
Unwind the RTREE dimension loop inside of rtreeCallbackConstraint(). check-in: 4854ea9c user: drh tags: trunk
16:41
Completely unroll the dimension loop inside of cellArea() in RTREE. check-in: 3c4c0126 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

  1074   1074     sqlite3_rtree_dbl *prScore,    /* OUT: score for the cell */
  1075   1075     int *peWithin                  /* OUT: visibility of the cell */
  1076   1076   ){
  1077   1077     int i;                                                /* Loop counter */
  1078   1078     sqlite3_rtree_query_info *pInfo = pConstraint->pInfo; /* Callback info */
  1079   1079     int nCoord = pInfo->nCoord;                           /* No. of coordinates */
  1080   1080     int rc;                                             /* Callback return code */
         1081  +  RtreeCoord c;                                       /* Translator union */
  1081   1082     sqlite3_rtree_dbl aCoord[RTREE_MAX_DIMENSIONS*2];   /* Decoded coordinates */
  1082   1083   
  1083   1084     assert( pConstraint->op==RTREE_MATCH || pConstraint->op==RTREE_QUERY );
  1084   1085     assert( nCoord==2 || nCoord==4 || nCoord==6 || nCoord==8 || nCoord==10 );
  1085   1086   
  1086   1087     if( pConstraint->op==RTREE_QUERY && pSearch->iLevel==1 ){
  1087   1088       pInfo->iRowid = readInt64(pCellData);
  1088   1089     }
  1089         -  assert( nCoord>=2 && (nCoord&1)==0 );
  1090         -  i = 0;
  1091         -  do{
  1092         -    pCellData += 8;
  1093         -    assert( ((((char*)pCellData) - (char*)0)&3)==0 );  /* 4-byte aligned */
  1094         -    RTREE_DECODE_COORD(eInt, pCellData, aCoord[i]);
  1095         -    RTREE_DECODE_COORD(eInt, (pCellData+4), aCoord[i+1]);
  1096         -    i+= 2;
  1097         -  }while( i<nCoord );
         1090  +  pCellData += 8;
         1091  +#ifndef SQLITE_RTREE_INT_ONLY
         1092  +  if( eInt==0 ){
         1093  +    switch( nCoord ){
         1094  +      case 10:  readCoord(pCellData+36, &c); aCoord[9] = c.f;
         1095  +                readCoord(pCellData+32, &c); aCoord[8] = c.f;
         1096  +      case 8:   readCoord(pCellData+28, &c); aCoord[7] = c.f;
         1097  +                readCoord(pCellData+24, &c); aCoord[6] = c.f;
         1098  +      case 6:   readCoord(pCellData+20, &c); aCoord[5] = c.f;
         1099  +                readCoord(pCellData+16, &c); aCoord[4] = c.f;
         1100  +      case 4:   readCoord(pCellData+12, &c); aCoord[3] = c.f;
         1101  +                readCoord(pCellData+8,  &c); aCoord[2] = c.f;
         1102  +      default:  readCoord(pCellData+4,  &c); aCoord[1] = c.f;
         1103  +                readCoord(pCellData,    &c); aCoord[0] = c.f;
         1104  +    }
         1105  +  }else
         1106  +#endif
         1107  +  {
         1108  +    switch( nCoord ){
         1109  +      case 10:  readCoord(pCellData+36, &c); aCoord[9] = c.i;
         1110  +                readCoord(pCellData+32, &c); aCoord[8] = c.i;
         1111  +      case 8:   readCoord(pCellData+28, &c); aCoord[7] = c.i;
         1112  +                readCoord(pCellData+24, &c); aCoord[6] = c.i;
         1113  +      case 6:   readCoord(pCellData+20, &c); aCoord[5] = c.i;
         1114  +                readCoord(pCellData+16, &c); aCoord[4] = c.i;
         1115  +      case 4:   readCoord(pCellData+12, &c); aCoord[3] = c.i;
         1116  +                readCoord(pCellData+8,  &c); aCoord[2] = c.i;
         1117  +      default:  readCoord(pCellData+4,  &c); aCoord[1] = c.i;
         1118  +                readCoord(pCellData,    &c); aCoord[0] = c.i;
         1119  +    }
         1120  +  }
  1098   1121     if( pConstraint->op==RTREE_MATCH ){
  1099   1122       rc = pConstraint->u.xGeom((sqlite3_rtree_geometry*)pInfo,
  1100   1123                                 nCoord, aCoord, &i);
  1101   1124       if( i==0 ) *peWithin = NOT_WITHIN;
  1102   1125       *prScore = RTREE_ZERO;
  1103   1126     }else{
  1104   1127       pInfo->aCoord = aCoord;