/ Check-in [470c6c07]
Login

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

Overview
Comment:Rig geopoly to use sqlite3AtoF() if it is available, as that routine is much faster than atof().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 470c6c07d0eb70806ac257c1c8ad877e041bbc14ff9a5c490edb51b2956ae726
User & Date: drh 2018-09-28 00:16:57
Context
2018-09-28
13:18
Make most geopoly functions pure. check-in: 944e167a user: drh tags: trunk
00:16
Rig geopoly to use sqlite3AtoF() if it is available, as that routine is much faster than atof(). check-in: 470c6c07 user: drh tags: trunk
2018-09-27
23:57
Small performance optimization in the JSON parser of Geopoly. check-in: fb520e71 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rtree/geopoly.c.

   154    154     if( c=='-' ){
   155    155       j = 1;
   156    156       c = z[j];
   157    157     }
   158    158     if( c=='0' && z[j+1]>='0' && z[j+1]<='9' ) return 0;
   159    159     for(;; j++){
   160    160       c = z[j];
   161         -    if( c>='0' && c<='9' ) continue;
          161  +    if( safe_isdigit(c) ) continue;
   162    162       if( c=='.' ){
   163    163         if( z[j-1]=='-' ) return 0;
   164    164         if( seenDP ) return 0;
   165    165         seenDP = 1;
   166    166         continue;
   167    167       }
   168    168       if( c=='e' || c=='E' ){
................................................................................
   176    176         }
   177    177         if( c<'0' || c>'9' ) return 0;
   178    178         continue;
   179    179       }
   180    180       break;
   181    181     }
   182    182     if( z[j-1]<'0' ) return 0;
   183         -  if( pVal ) *pVal = (GeoCoord)atof((const char*)p->z);
          183  +  if( pVal ){
          184  +#ifdef SQLITE_AMALGAMATION
          185  +     /* The sqlite3AtoF() routine is much much faster than atof(), if it
          186  +     ** is available */
          187  +     double r;
          188  +     (void)sqlite3AtoF((const char*)p->z, &r, j, SQLITE_UTF8);
          189  +     *pVal = r;
          190  +#else
          191  +     *pVal = (GeoCoord)atof((const char*)p->z);
          192  +#endif
          193  +  }
   184    194     p->z += j;
   185    195     return 1;
   186    196   }
   187    197   
   188    198   /*
   189    199   ** If the input is a well-formed JSON array of coordinates with at least
   190    200   ** four coordinates and where each coordinate is itself a two-value array,