Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Optimization to the round() SQL function for large input values without a fractional part. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
e95138f5f4febde598f39e031d6e4f4d |
User & Date: | drh 2019-05-30 13:47:10 |
References
2019-06-07
| ||
22:51 | Remove code in the round() SQL function that became unreachable due to the optimization of check-in [e95138f5f4febde5] (check-in: b141bae3 user: drh tags: trunk) | |
Context
2019-06-03
| ||
15:09 | Fix harmless compiler warning in lemon. (check-in: 2da0eea0 user: mistachkin tags: trunk) | |
2019-05-30
| ||
13:47 | Optimization to the round() SQL function for large input values without a fractional part. (check-in: e95138f5 user: drh tags: trunk) | |
00:46 | Smaller and faster sqlite3IsNaN() implementation makes deserialization of floating point values much faster. (check-in: ea748ede user: drh tags: trunk) | |
Changes
Changes to src/func.c.
︙ | ︙ | |||
383 384 385 386 387 388 389 | } if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; r = sqlite3_value_double(argv[0]); /* If Y==0 and X will fit in a 64-bit int, ** handle the rounding directly, ** otherwise use printf. */ | | | | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 | } if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return; r = sqlite3_value_double(argv[0]); /* If Y==0 and X will fit in a 64-bit int, ** handle the rounding directly, ** otherwise use printf. */ if( r<-4503599627370496.0 || r>+4503599627370496.0 ){ /* The value has no fractional part so there is nothing to round */ }else if( n==0 ){ r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5))); }else{ zBuf = sqlite3_mprintf("%.*f",n,r); if( zBuf==0 ){ sqlite3_result_error_nomem(context); return; } if( !sqlite3AtoF(zBuf, &r, sqlite3Strlen30(zBuf), SQLITE_UTF8) ){ |
︙ | ︙ |
Changes to src/util.c.
︙ | ︙ | |||
400 401 402 403 404 405 406 407 408 409 410 411 412 413 | if( enc==SQLITE_UTF8 ){ incr = 1; }else{ int i; incr = 2; assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); for(i=3-enc; i<length && z[i]==0; i+=2){} if( i<length ) eType = -100; zEnd = &z[i^1]; z += (enc&1); } /* skip leading spaces */ | > > | 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | if( enc==SQLITE_UTF8 ){ incr = 1; }else{ int i; incr = 2; assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 ); testcase( enc==SQLITE_UTF16LE ); testcase( enc==SQLITE_UTF16BE ); for(i=3-enc; i<length && z[i]==0; i+=2){} if( i<length ) eType = -100; zEnd = &z[i^1]; z += (enc&1); } /* skip leading spaces */ |
︙ | ︙ |