oj 3.13.17 → 3.13.18
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/CHANGELOG.md +4 -0
- data/ext/oj/custom.c +7 -7
- data/ext/oj/dump.c +2 -2
- data/ext/oj/dump_compat.c +5 -5
- data/ext/oj/dump_object.c +3 -3
- data/ext/oj/dump_strict.c +5 -5
- data/ext/oj/extconf.rb +14 -2
- data/ext/oj/oj.c +1 -0
- data/ext/oj/parse.c +72 -49
- data/ext/oj/parse.h +2 -0
- data/ext/oj/rails.c +5 -5
- data/ext/oj/wab.c +2 -2
- data/lib/oj/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7ca20e7921e7b9a3e2838ecbe3505ecb736bce338113a3db3187f411d1762ca
|
4
|
+
data.tar.gz: 6c09a24ddb7017caa2a2850076a6b0fcbccc6ed27cd6e28e28de7fadacbaa7fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1bb01e19979391421d87b0598ff543ce3035a86fcbb06a68b63d4b56f4194739213d506fdd0492f5cf4a2aabd037872935fcb16f5d083fd6e532c6aa869b8d
|
7
|
+
data.tar.gz: 29db51398d6008cbcb827af666da0b41b750f6aea3e561fe37b2354f48b88d2bf393dcbfed931679072042bd19cf179ec0ae674027527b627391c2c4792f3c63
|
data/CHANGELOG.md
CHANGED
data/ext/oj/custom.c
CHANGED
@@ -484,7 +484,7 @@ static VALUE dump_common(VALUE obj, int depth, Out out) {
|
|
484
484
|
const char * s;
|
485
485
|
int len;
|
486
486
|
|
487
|
-
if (Yes == out->opts->trace) {
|
487
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
488
488
|
oj_trace("to_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyIn);
|
489
489
|
}
|
490
490
|
if (0 == rb_obj_method_arity(obj, oj_to_json_id)) {
|
@@ -492,7 +492,7 @@ static VALUE dump_common(VALUE obj, int depth, Out out) {
|
|
492
492
|
} else {
|
493
493
|
rs = rb_funcall2(obj, oj_to_json_id, out->argc, out->argv);
|
494
494
|
}
|
495
|
-
if (Yes == out->opts->trace) {
|
495
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
496
496
|
oj_trace("to_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyOut);
|
497
497
|
}
|
498
498
|
s = RSTRING_PTR(rs);
|
@@ -504,7 +504,7 @@ static VALUE dump_common(VALUE obj, int depth, Out out) {
|
|
504
504
|
} else if (Yes == out->opts->as_json && rb_respond_to(obj, oj_as_json_id)) {
|
505
505
|
volatile VALUE aj;
|
506
506
|
|
507
|
-
if (Yes == out->opts->trace) {
|
507
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
508
508
|
oj_trace("as_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyIn);
|
509
509
|
}
|
510
510
|
// Some classes elect to not take an options argument so check the arity
|
@@ -514,7 +514,7 @@ static VALUE dump_common(VALUE obj, int depth, Out out) {
|
|
514
514
|
} else {
|
515
515
|
aj = rb_funcall2(obj, oj_as_json_id, out->argc, out->argv);
|
516
516
|
}
|
517
|
-
if (Yes == out->opts->trace) {
|
517
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
518
518
|
oj_trace("as_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyOut);
|
519
519
|
}
|
520
520
|
// Catch the obvious brain damaged recursive dumping.
|
@@ -885,7 +885,7 @@ static DumpFunc custom_funcs[] = {
|
|
885
885
|
void oj_dump_custom_val(VALUE obj, int depth, Out out, bool as_ok) {
|
886
886
|
int type = rb_type(obj);
|
887
887
|
|
888
|
-
if (Yes == out->opts->trace) {
|
888
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
889
889
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceIn);
|
890
890
|
}
|
891
891
|
if (MAX_DEPTH < depth) {
|
@@ -896,14 +896,14 @@ void oj_dump_custom_val(VALUE obj, int depth, Out out, bool as_ok) {
|
|
896
896
|
|
897
897
|
if (NULL != f) {
|
898
898
|
f(obj, depth, out, true);
|
899
|
-
if (Yes == out->opts->trace) {
|
899
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
900
900
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
901
901
|
}
|
902
902
|
return;
|
903
903
|
}
|
904
904
|
}
|
905
905
|
oj_dump_nil(Qnil, depth, out, false);
|
906
|
-
if (Yes == out->opts->trace) {
|
906
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
907
907
|
oj_trace("dump", Qnil, __FILE__, __LINE__, depth, TraceOut);
|
908
908
|
}
|
909
909
|
}
|
data/ext/oj/dump.c
CHANGED
@@ -736,11 +736,11 @@ void oj_dump_raw_json(VALUE obj, int depth, Out out) {
|
|
736
736
|
} else {
|
737
737
|
volatile VALUE jv;
|
738
738
|
|
739
|
-
if (Yes == out->opts->trace) {
|
739
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
740
740
|
oj_trace("raw_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyIn);
|
741
741
|
}
|
742
742
|
jv = rb_funcall(obj, oj_raw_json_id, 2, RB_INT2NUM(depth), RB_INT2NUM(out->indent));
|
743
|
-
if (Yes == out->opts->trace) {
|
743
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
744
744
|
oj_trace("raw_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyOut);
|
745
745
|
}
|
746
746
|
oj_dump_raw(RSTRING_PTR(jv), (size_t)RSTRING_LEN(jv), out);
|
data/ext/oj/dump_compat.c
CHANGED
@@ -109,7 +109,7 @@ dump_to_json(VALUE obj, Out out) {
|
|
109
109
|
const char *s;
|
110
110
|
int len;
|
111
111
|
|
112
|
-
if (Yes == out->opts->trace) {
|
112
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
113
113
|
oj_trace("to_json", obj, __FILE__, __LINE__, 0, TraceRubyIn);
|
114
114
|
}
|
115
115
|
if (0 == rb_obj_method_arity(obj, oj_to_json_id)) {
|
@@ -117,7 +117,7 @@ dump_to_json(VALUE obj, Out out) {
|
|
117
117
|
} else {
|
118
118
|
rs = rb_funcall2(obj, oj_to_json_id, out->argc, out->argv);
|
119
119
|
}
|
120
|
-
if (Yes == out->opts->trace) {
|
120
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
121
121
|
oj_trace("to_json", obj, __FILE__, __LINE__, 0, TraceRubyOut);
|
122
122
|
}
|
123
123
|
|
@@ -893,7 +893,7 @@ void
|
|
893
893
|
oj_dump_compat_val(VALUE obj, int depth, Out out, bool as_ok) {
|
894
894
|
int type = rb_type(obj);
|
895
895
|
|
896
|
-
if (Yes == out->opts->trace) {
|
896
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
897
897
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceIn);
|
898
898
|
}
|
899
899
|
if (out->opts->dump_opts.max_depth <= depth) {
|
@@ -918,14 +918,14 @@ oj_dump_compat_val(VALUE obj, int depth, Out out, bool as_ok) {
|
|
918
918
|
|
919
919
|
if (NULL != f) {
|
920
920
|
f(obj, depth, out, as_ok);
|
921
|
-
if (Yes == out->opts->trace) {
|
921
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
922
922
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
923
923
|
}
|
924
924
|
return;
|
925
925
|
}
|
926
926
|
}
|
927
927
|
oj_dump_nil(Qnil, depth, out, false);
|
928
|
-
if (Yes == out->opts->trace) {
|
928
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
929
929
|
oj_trace("dump", Qnil, __FILE__, __LINE__, depth, TraceOut);
|
930
930
|
}
|
931
931
|
}
|
data/ext/oj/dump_object.c
CHANGED
@@ -682,7 +682,7 @@ static DumpFunc obj_funcs[] = {
|
|
682
682
|
void oj_dump_obj_val(VALUE obj, int depth, Out out) {
|
683
683
|
int type = rb_type(obj);
|
684
684
|
|
685
|
-
if (Yes == out->opts->trace) {
|
685
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
686
686
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceIn);
|
687
687
|
}
|
688
688
|
if (MAX_DEPTH < depth) {
|
@@ -693,14 +693,14 @@ void oj_dump_obj_val(VALUE obj, int depth, Out out) {
|
|
693
693
|
|
694
694
|
if (NULL != f) {
|
695
695
|
f(obj, depth, out, false);
|
696
|
-
if (Yes == out->opts->trace) {
|
696
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
697
697
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
698
698
|
}
|
699
699
|
return;
|
700
700
|
}
|
701
701
|
}
|
702
702
|
oj_dump_nil(Qnil, depth, out, false);
|
703
|
-
if (Yes == out->opts->trace) {
|
703
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
704
704
|
oj_trace("dump", Qnil, __FILE__, __LINE__, depth, TraceOut);
|
705
705
|
}
|
706
706
|
}
|
data/ext/oj/dump_strict.c
CHANGED
@@ -338,7 +338,7 @@ static DumpFunc strict_funcs[] = {
|
|
338
338
|
void oj_dump_strict_val(VALUE obj, int depth, Out out) {
|
339
339
|
int type = rb_type(obj);
|
340
340
|
|
341
|
-
if (Yes == out->opts->trace) {
|
341
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
342
342
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceIn);
|
343
343
|
}
|
344
344
|
if (MAX_DEPTH < depth) {
|
@@ -349,7 +349,7 @@ void oj_dump_strict_val(VALUE obj, int depth, Out out) {
|
|
349
349
|
|
350
350
|
if (NULL != f) {
|
351
351
|
f(obj, depth, out, false);
|
352
|
-
if (Yes == out->opts->trace) {
|
352
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
353
353
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
354
354
|
}
|
355
355
|
return;
|
@@ -386,7 +386,7 @@ static DumpFunc null_funcs[] = {
|
|
386
386
|
void oj_dump_null_val(VALUE obj, int depth, Out out) {
|
387
387
|
int type = rb_type(obj);
|
388
388
|
|
389
|
-
if (Yes == out->opts->trace) {
|
389
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
390
390
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
391
391
|
}
|
392
392
|
if (MAX_DEPTH < depth) {
|
@@ -397,14 +397,14 @@ void oj_dump_null_val(VALUE obj, int depth, Out out) {
|
|
397
397
|
|
398
398
|
if (NULL != f) {
|
399
399
|
f(obj, depth, out, false);
|
400
|
-
if (Yes == out->opts->trace) {
|
400
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
401
401
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
402
402
|
}
|
403
403
|
return;
|
404
404
|
}
|
405
405
|
}
|
406
406
|
oj_dump_nil(Qnil, depth, out, false);
|
407
|
-
if (Yes == out->opts->trace) {
|
407
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
408
408
|
oj_trace("dump", Qnil, __FILE__, __LINE__, depth, TraceOut);
|
409
409
|
}
|
410
410
|
}
|
data/ext/oj/extconf.rb
CHANGED
@@ -34,9 +34,21 @@ have_func('rb_hash_bulk_insert', 'ruby.h') unless '2' == version[0] && '6' == ve
|
|
34
34
|
|
35
35
|
dflags['OJ_DEBUG'] = true unless ENV['OJ_DEBUG'].nil?
|
36
36
|
|
37
|
-
|
37
|
+
src =<<~SRC
|
38
|
+
#include <string.h>
|
39
|
+
#include <nmmintrin.h>
|
40
|
+
int main(int argc, char **argv) {
|
41
|
+
const char *str = "hello ";
|
42
|
+
const char chars[16] = "\x00\\\"";
|
43
|
+
const __m128i terminate = _mm_loadu_si128((const __m128i *)&chars[0]);
|
44
|
+
const __m128i string = _mm_loadu_si128((const __m128i *)str);
|
45
|
+
int r = _mm_cmpestri(terminate, 3, string, 16, _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_ANY | _SIDD_LEAST_SIGNIFICANT);
|
46
|
+
return r == 16 ? 0 : 1;
|
47
|
+
}
|
48
|
+
SRC
|
49
|
+
|
50
|
+
if try_run(src, '-msse4.2')
|
38
51
|
$CPPFLAGS += ' -msse4.2'
|
39
|
-
dflags['OJ_USE_SSE4_2'] = 1
|
40
52
|
end
|
41
53
|
|
42
54
|
dflags.each do |k,v|
|
data/ext/oj/oj.c
CHANGED
data/ext/oj/parse.c
CHANGED
@@ -192,7 +192,26 @@ static inline const char *scan_string_noSIMD(const char *str, const char *end) {
|
|
192
192
|
return str;
|
193
193
|
}
|
194
194
|
|
195
|
-
|
195
|
+
// Taken from Tensorflow:
|
196
|
+
// https://github.com/tensorflow/tensorflow/blob/5dcfc51118817f27fad5246812d83e5dccdc5f72/tensorflow/core/lib/hash/crc32c_accelerate.cc#L21-L38
|
197
|
+
#ifdef __SSE4_2__
|
198
|
+
#if defined(__x86_64__) && defined(__GNUC__) && \
|
199
|
+
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
|
200
|
+
#define USE_SSE_DETECT 1
|
201
|
+
#elif defined(__x86_64__) && defined(__clang__)
|
202
|
+
#if __has_builtin(__builtin_cpu_supports)
|
203
|
+
#define USE_SSE_DETECT 1
|
204
|
+
#endif
|
205
|
+
#endif
|
206
|
+
#endif /* __SSE4_2__ */
|
207
|
+
|
208
|
+
// This version of Apple clang has a bug:
|
209
|
+
// https://llvm.org/bugs/show_bug.cgi?id=25510
|
210
|
+
#if defined(__APPLE__) && (__clang_major__ <= 8)
|
211
|
+
#undef USE_SSE_DETECT
|
212
|
+
#endif
|
213
|
+
|
214
|
+
#ifdef USE_SSE_DETECT
|
196
215
|
#include <nmmintrin.h>
|
197
216
|
|
198
217
|
static inline const char *scan_string_SIMD(const char *str, const char *end) {
|
@@ -213,6 +232,25 @@ static inline const char *scan_string_SIMD(const char *str, const char *end) {
|
|
213
232
|
}
|
214
233
|
#endif
|
215
234
|
|
235
|
+
static bool cpu_supports_sse42(void) {
|
236
|
+
#if USE_SSE_DETECT
|
237
|
+
__builtin_cpu_init();
|
238
|
+
return (__builtin_cpu_supports("sse4.2"));
|
239
|
+
#else
|
240
|
+
return false;
|
241
|
+
#endif
|
242
|
+
}
|
243
|
+
|
244
|
+
static const char *(*scan_func) (const char *str, const char *end) = scan_string_noSIMD;
|
245
|
+
|
246
|
+
void oj_scanner_init(void) {
|
247
|
+
if (cpu_supports_sse42()) {
|
248
|
+
#if USE_SSE_DETECT
|
249
|
+
scan_func = scan_string_SIMD;
|
250
|
+
#endif
|
251
|
+
}
|
252
|
+
}
|
253
|
+
|
216
254
|
// entered at /
|
217
255
|
static void read_escaped_str(ParseInfo pi, const char *start) {
|
218
256
|
struct _buf buf;
|
@@ -225,11 +263,7 @@ static void read_escaped_str(ParseInfo pi, const char *start) {
|
|
225
263
|
buf_append_string(&buf, start, cnt);
|
226
264
|
|
227
265
|
for (s = pi->cur; '"' != *s;) {
|
228
|
-
|
229
|
-
const char *scanned = scan_string_SIMD(s, pi->end);
|
230
|
-
#else
|
231
|
-
const char *scanned = scan_string_noSIMD(s, pi->end);
|
232
|
-
#endif
|
266
|
+
const char *scanned = scan_func(s, pi->end);
|
233
267
|
if (scanned >= pi->end) {
|
234
268
|
oj_set_error_at(pi,
|
235
269
|
oj_parse_error_class,
|
@@ -369,11 +403,7 @@ static void read_str(ParseInfo pi) {
|
|
369
403
|
const char *str = pi->cur;
|
370
404
|
Val parent = stack_peek(&pi->stack);
|
371
405
|
|
372
|
-
|
373
|
-
pi->cur = scan_string_SIMD(pi->cur, pi->end);
|
374
|
-
#else
|
375
|
-
pi->cur = scan_string_noSIMD(pi->cur, pi->end);
|
376
|
-
#endif
|
406
|
+
pi->cur = scan_func(pi->cur, pi->end);
|
377
407
|
if (RB_UNLIKELY(pi->end <= pi->cur)) {
|
378
408
|
oj_set_error_at(pi,
|
379
409
|
oj_parse_error_class,
|
@@ -503,33 +533,31 @@ static void read_num(ParseInfo pi) {
|
|
503
533
|
int dec_cnt = 0;
|
504
534
|
bool zero1 = false;
|
505
535
|
|
536
|
+
// Skip leading zeros.
|
537
|
+
for (; '0' == *pi->cur; pi->cur++) {
|
538
|
+
zero1 = true;
|
539
|
+
}
|
540
|
+
|
506
541
|
for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
|
507
|
-
|
508
|
-
zero1 = true;
|
509
|
-
}
|
510
|
-
if (0 < ni.i) {
|
511
|
-
dec_cnt++;
|
512
|
-
}
|
513
|
-
if (!ni.big) {
|
514
|
-
int d = (*pi->cur - '0');
|
542
|
+
int d = (*pi->cur - '0');
|
515
543
|
|
516
|
-
|
517
|
-
|
518
|
-
oj_set_error_at(pi,
|
519
|
-
oj_parse_error_class,
|
520
|
-
__FILE__,
|
521
|
-
__LINE__,
|
522
|
-
"not a number");
|
523
|
-
return;
|
524
|
-
}
|
525
|
-
zero1 = false;
|
526
|
-
}
|
527
|
-
ni.i = ni.i * 10 + d;
|
528
|
-
if (INT64_MAX <= ni.i || DEC_MAX < dec_cnt) {
|
529
|
-
ni.big = 1;
|
530
|
-
}
|
544
|
+
if (RB_LIKELY(0 != ni.i)) {
|
545
|
+
dec_cnt++;
|
531
546
|
}
|
547
|
+
ni.i = ni.i * 10 + d;
|
548
|
+
}
|
549
|
+
if (RB_UNLIKELY(0 != ni.i && zero1 && CompatMode == pi->options.mode)) {
|
550
|
+
oj_set_error_at(pi,
|
551
|
+
oj_parse_error_class,
|
552
|
+
__FILE__,
|
553
|
+
__LINE__,
|
554
|
+
"not a number");
|
555
|
+
return;
|
556
|
+
}
|
557
|
+
if (INT64_MAX <= ni.i || DEC_MAX < dec_cnt) {
|
558
|
+
ni.big = true;
|
532
559
|
}
|
560
|
+
|
533
561
|
if ('.' == *pi->cur) {
|
534
562
|
pi->cur++;
|
535
563
|
// A trailing . is not a valid decimal but if encountered allow it
|
@@ -549,25 +577,20 @@ static void read_num(ParseInfo pi) {
|
|
549
577
|
for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
|
550
578
|
int d = (*pi->cur - '0');
|
551
579
|
|
552
|
-
if (0
|
580
|
+
if (RB_LIKELY(0 != ni.num || 0 != ni.i)) {
|
553
581
|
dec_cnt++;
|
554
582
|
}
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
}
|
559
|
-
} else {
|
560
|
-
ni.num = ni.num * 10 + d;
|
561
|
-
ni.div *= 10;
|
562
|
-
ni.di++;
|
563
|
-
if (INT64_MAX <= ni.div || DEC_MAX < dec_cnt) {
|
564
|
-
if (!ni.no_big) {
|
565
|
-
ni.big = true;
|
566
|
-
}
|
567
|
-
}
|
568
|
-
}
|
583
|
+
ni.num = ni.num * 10 + d;
|
584
|
+
ni.div *= 10;
|
585
|
+
ni.di++;
|
569
586
|
}
|
570
587
|
}
|
588
|
+
if (INT64_MAX <= ni.div || DEC_MAX < dec_cnt) {
|
589
|
+
if (!ni.no_big) {
|
590
|
+
ni.big = true;
|
591
|
+
}
|
592
|
+
}
|
593
|
+
|
571
594
|
if ('e' == *pi->cur || 'E' == *pi->cur) {
|
572
595
|
int eneg = 0;
|
573
596
|
|
data/ext/oj/parse.h
CHANGED
data/ext/oj/rails.c
CHANGED
@@ -517,7 +517,7 @@ static void dump_as_string(VALUE obj, int depth, Out out, bool as_ok) {
|
|
517
517
|
static void dump_as_json(VALUE obj, int depth, Out out, bool as_ok) {
|
518
518
|
volatile VALUE ja;
|
519
519
|
|
520
|
-
if (Yes == out->opts->trace) {
|
520
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
521
521
|
oj_trace("as_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyIn);
|
522
522
|
}
|
523
523
|
// Some classes elect to not take an options argument so check the arity
|
@@ -527,7 +527,7 @@ static void dump_as_json(VALUE obj, int depth, Out out, bool as_ok) {
|
|
527
527
|
} else {
|
528
528
|
ja = rb_funcall2(obj, oj_as_json_id, out->argc, out->argv);
|
529
529
|
}
|
530
|
-
if (Yes == out->opts->trace) {
|
530
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
531
531
|
oj_trace("as_json", obj, __FILE__, __LINE__, depth + 1, TraceRubyOut);
|
532
532
|
}
|
533
533
|
|
@@ -1464,7 +1464,7 @@ static DumpFunc rails_funcs[] = {
|
|
1464
1464
|
static void dump_rails_val(VALUE obj, int depth, Out out, bool as_ok) {
|
1465
1465
|
int type = rb_type(obj);
|
1466
1466
|
|
1467
|
-
if (Yes == out->opts->trace) {
|
1467
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
1468
1468
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceIn);
|
1469
1469
|
}
|
1470
1470
|
if (MAX_DEPTH < depth) {
|
@@ -1475,14 +1475,14 @@ static void dump_rails_val(VALUE obj, int depth, Out out, bool as_ok) {
|
|
1475
1475
|
|
1476
1476
|
if (NULL != f) {
|
1477
1477
|
f(obj, depth, out, as_ok);
|
1478
|
-
if (Yes == out->opts->trace) {
|
1478
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
1479
1479
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
1480
1480
|
}
|
1481
1481
|
return;
|
1482
1482
|
}
|
1483
1483
|
}
|
1484
1484
|
oj_dump_nil(Qnil, depth, out, false);
|
1485
|
-
if (Yes == out->opts->trace) {
|
1485
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
1486
1486
|
oj_trace("dump", Qnil, __FILE__, __LINE__, depth, TraceOut);
|
1487
1487
|
}
|
1488
1488
|
}
|
data/ext/oj/wab.c
CHANGED
@@ -266,7 +266,7 @@ static DumpFunc wab_funcs[] = {
|
|
266
266
|
void oj_dump_wab_val(VALUE obj, int depth, Out out) {
|
267
267
|
int type = rb_type(obj);
|
268
268
|
|
269
|
-
if (Yes == out->opts->trace) {
|
269
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
270
270
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceIn);
|
271
271
|
}
|
272
272
|
if (MAX_DEPTH < depth) {
|
@@ -277,7 +277,7 @@ void oj_dump_wab_val(VALUE obj, int depth, Out out) {
|
|
277
277
|
|
278
278
|
if (NULL != f) {
|
279
279
|
f(obj, depth, out, false);
|
280
|
-
if (Yes == out->opts->trace) {
|
280
|
+
if (RB_UNLIKELY(Yes == out->opts->trace)) {
|
281
281
|
oj_trace("dump", obj, __FILE__, __LINE__, depth, TraceOut);
|
282
282
|
}
|
283
283
|
return;
|
data/lib/oj/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.13.
|
4
|
+
version: 3.13.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|