ext/oj/compat.c in oj-3.13.23 vs ext/oj/compat.c in oj-3.14.0

- old
+ new

@@ -52,13 +52,11 @@ // the unit tests. rb_funcall(parent->val, rb_intern("[]="), 2, rkey, rstr); } else { rb_hash_aset(parent->val, rkey, rstr); } - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_call("set_string", pi, __FILE__, __LINE__, rstr); - } + TRACE_PARSE_CALL(pi->options.trace, "set_string", pi, rstr); } } static VALUE start_hash(ParseInfo pi) { volatile VALUE h; @@ -66,13 +64,11 @@ if (Qnil != pi->options.hash_class) { h = rb_class_new_instance(0, NULL, pi->options.hash_class); } else { h = rb_hash_new(); } - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_in("start_hash", pi, __FILE__, __LINE__); - } + TRACE_PARSE_IN(pi->options.trace, "start_hash", pi); return h; } static void end_hash(struct _parseInfo *pi) { Val parent = stack_peek(&pi->stack); @@ -91,13 +87,11 @@ if (0 != parent->classname) { xfree((char *)parent->classname); parent->classname = 0; } } - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_hash_end(pi, __FILE__, __LINE__); - } + TRACE_PARSE_HASH_END(pi->options.trace, pi); } static void add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) { volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str); @@ -108,20 +102,16 @@ pi->stack.head->val = rb_funcall(clas, oj_json_create_id, 1, rstr); return; } } pi->stack.head->val = rstr; - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_call("add_string", pi, __FILE__, __LINE__, rstr); - } + TRACE_PARSE_CALL(pi->options.trace, "add_string", pi, rstr); } static void add_num(ParseInfo pi, NumInfo ni) { pi->stack.head->val = oj_num_as_value(ni); - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_call("add_number", pi, __FILE__, __LINE__, pi->stack.head->val); - } + TRACE_PARSE_CALL(pi->options.trace, "add_number", pi, pi->stack.head->val); } static void hash_set_num(struct _parseInfo *pi, Val parent, NumInfo ni) { volatile VALUE rval = oj_num_as_value(ni); @@ -136,13 +126,11 @@ oj_calc_hash_key(pi, parent), rval); } else { rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), rval); } - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_call("set_number", pi, __FILE__, __LINE__, rval); - } + TRACE_PARSE_CALL(pi->options.trace, "set_number", pi, rval); } static void hash_set_value(ParseInfo pi, Val parent, VALUE value) { if (rb_cHash != rb_obj_class(parent->val)) { // The rb_hash_set would still work but the unit tests for the @@ -155,22 +143,18 @@ oj_calc_hash_key(pi, parent), value); } else { rb_hash_aset(stack_peek(&pi->stack)->val, oj_calc_hash_key(pi, parent), value); } - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_call("set_value", pi, __FILE__, __LINE__, value); - } + TRACE_PARSE_CALL(pi->options.trace, "set_value", pi, value); } static VALUE start_array(ParseInfo pi) { if (Qnil != pi->options.array_class) { return rb_class_new_instance(0, NULL, pi->options.array_class); } - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_in("start_array", pi, __FILE__, __LINE__); - } + TRACE_PARSE_IN(pi->options.trace, "start_array", pi); return rb_ary_new(); } static void array_append_num(ParseInfo pi, NumInfo ni) { Val parent = stack_peek(&pi->stack); @@ -182,13 +166,11 @@ // values. rb_funcall(parent->val, rb_intern("<<"), 1, rval); } else { rb_ary_push(parent->val, rval); } - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_call("append_number", pi, __FILE__, __LINE__, rval); - } + TRACE_PARSE_CALL(pi->options.trace, "append_number", pi, rval); } static void array_append_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) { volatile VALUE rstr = oj_cstr_to_value(str, len, (size_t)pi->options.cache_str); @@ -199,12 +181,10 @@ rb_ary_push(stack_peek(&pi->stack)->val, rb_funcall(clas, oj_json_create_id, 1, rstr)); return; } } rb_ary_push(stack_peek(&pi->stack)->val, rstr); - if (RB_UNLIKELY(Yes == pi->options.trace)) { - oj_trace_parse_call("append_string", pi, __FILE__, __LINE__, rstr); - } + TRACE_PARSE_CALL(pi->options.trace, "append_string", pi, rstr); } void oj_set_compat_callbacks(ParseInfo pi) { oj_set_strict_callbacks(pi); pi->start_hash = start_hash;