json 2.13.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +208 -8
- data/LEGAL +12 -0
- data/README.md +34 -87
- data/ext/json/ext/fbuffer/fbuffer.h +75 -86
- data/ext/json/ext/generator/extconf.rb +4 -1
- data/ext/json/ext/generator/generator.c +494 -596
- data/ext/json/ext/json.h +196 -0
- data/ext/json/ext/parser/extconf.rb +29 -1
- data/ext/json/ext/parser/parser.c +2091 -723
- data/ext/json/ext/simd/simd.h +42 -22
- data/ext/json/ext/vendor/fast_float_parser.h +814 -0
- data/ext/json/ext/vendor/fpconv.c +13 -12
- data/lib/json/common.rb +199 -389
- data/lib/json/ext/generator/state.rb +8 -37
- data/lib/json/ext.rb +25 -1
- data/lib/json/truffle_ruby/generator.rb +186 -128
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +84 -252
- metadata +5 -18
- data/lib/json/add/bigdecimal.rb +0 -58
- data/lib/json/add/complex.rb +0 -51
- data/lib/json/add/core.rb +0 -12
- data/lib/json/add/date.rb +0 -54
- data/lib/json/add/date_time.rb +0 -67
- data/lib/json/add/exception.rb +0 -49
- data/lib/json/add/ostruct.rb +0 -54
- data/lib/json/add/range.rb +0 -54
- data/lib/json/add/rational.rb +0 -49
- data/lib/json/add/regexp.rb +0 -48
- data/lib/json/add/set.rb +0 -48
- data/lib/json/add/struct.rb +0 -52
- data/lib/json/add/symbol.rb +0 -52
- data/lib/json/add/time.rb +0 -52
- data/lib/json/generic_object.rb +0 -75
|
@@ -29,6 +29,10 @@
|
|
|
29
29
|
#include <string.h>
|
|
30
30
|
#include <stdint.h>
|
|
31
31
|
|
|
32
|
+
#if JSON_DEBUG
|
|
33
|
+
#include <assert.h>
|
|
34
|
+
#endif
|
|
35
|
+
|
|
32
36
|
#define npowers 87
|
|
33
37
|
#define steppowers 8
|
|
34
38
|
#define firstpower -348 /* 10 ^ -348 */
|
|
@@ -320,15 +324,7 @@ static int emit_digits(char* digits, int ndigits, char* dest, int K, bool neg)
|
|
|
320
324
|
{
|
|
321
325
|
int exp = absv(K + ndigits - 1);
|
|
322
326
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if(neg) {
|
|
326
|
-
max_trailing_zeros -= 1;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
/* write plain integer */
|
|
330
|
-
if(K >= 0 && (exp < (ndigits + max_trailing_zeros))) {
|
|
331
|
-
|
|
327
|
+
if(K >= 0 && exp < 15) {
|
|
332
328
|
memcpy(dest, digits, ndigits);
|
|
333
329
|
memset(dest + ndigits, '0', K);
|
|
334
330
|
|
|
@@ -432,10 +428,12 @@ static int filter_special(double fp, char* dest)
|
|
|
432
428
|
*
|
|
433
429
|
* Input:
|
|
434
430
|
* fp -> the double to convert, dest -> destination buffer.
|
|
435
|
-
* The generated string will never be longer than
|
|
436
|
-
* Make sure to pass a pointer to at least
|
|
431
|
+
* The generated string will never be longer than 32 characters.
|
|
432
|
+
* Make sure to pass a pointer to at least 32 bytes of memory.
|
|
437
433
|
* The emitted string will not be null terminated.
|
|
438
434
|
*
|
|
435
|
+
*
|
|
436
|
+
*
|
|
439
437
|
* Output:
|
|
440
438
|
* The number of written characters.
|
|
441
439
|
*
|
|
@@ -451,7 +449,7 @@ static int filter_special(double fp, char* dest)
|
|
|
451
449
|
* }
|
|
452
450
|
*
|
|
453
451
|
*/
|
|
454
|
-
static int fpconv_dtoa(double d, char dest[
|
|
452
|
+
static int fpconv_dtoa(double d, char dest[32])
|
|
455
453
|
{
|
|
456
454
|
char digits[18];
|
|
457
455
|
|
|
@@ -474,6 +472,9 @@ static int fpconv_dtoa(double d, char dest[28])
|
|
|
474
472
|
int ndigits = grisu2(d, digits, &K);
|
|
475
473
|
|
|
476
474
|
str_len += emit_digits(digits, ndigits, dest + str_len, K, neg);
|
|
475
|
+
#if JSON_DEBUG
|
|
476
|
+
assert(str_len <= 32);
|
|
477
|
+
#endif
|
|
477
478
|
|
|
478
479
|
return str_len;
|
|
479
480
|
}
|