mirror of
https://github.com/ruby/ruby.git
synced 2025-08-23 13:04:13 +02:00
[ruby/json] Directly use generate_json_string
for object keys
... instead of `generate_json`.
Since the object key is already confirmed to be a string, using a
generic dispatch function brings an unnecessary overhead.
This speeds up `JSON.generate` by about 3% in a benchmark.
e125072130
This commit is contained in:
parent
3911189fba
commit
fb84aa5501
1 changed files with 5 additions and 1 deletions
|
@ -1,6 +1,10 @@
|
|||
#include "../fbuffer/fbuffer.h"
|
||||
#include "generator.h"
|
||||
|
||||
#ifndef RB_UNLIKELY
|
||||
#define RB_UNLIKELY(cond) (cond)
|
||||
#endif
|
||||
|
||||
static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
|
||||
mHash, mArray,
|
||||
#ifdef RUBY_INTEGER_UNIFICATION
|
||||
|
@ -678,7 +682,7 @@ json_object_i(VALUE key, VALUE val, VALUE _arg)
|
|||
break;
|
||||
}
|
||||
|
||||
generate_json(buffer, Vstate, state, key_to_s);
|
||||
generate_json_string(buffer, Vstate, state, key_to_s);
|
||||
fbuffer_append(buffer, delim2, delim2_len);
|
||||
generate_json(buffer, Vstate, state, val);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue