Skip to content

Commit 357d346

Browse files
committed
Don't copy JSON_Generator_State in generate_new
Now that the state isn't mutated in generate_new, we no longer need to copy the struct, we can just use it.
1 parent 61f6830 commit 357d346

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

ext/json/ext/generator/generator.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,12 +1537,6 @@ static VALUE cState_generate_new(int argc, VALUE *argv, VALUE self)
15371537

15381538
GET_STATE(self);
15391539

1540-
JSON_Generator_State new_state;
1541-
MEMCPY(&new_state, state, JSON_Generator_State, 1);
1542-
1543-
// FIXME: depth shouldn't be part of JSON_Generator_State, as that prevents it from being used concurrently.
1544-
new_state.depth = 0;
1545-
15461540
char stack_buffer[FBUFFER_STACK_SIZE];
15471541
FBuffer buffer = {
15481542
.io = RTEST(io) ? io : Qfalse,
@@ -1552,8 +1546,8 @@ static VALUE cState_generate_new(int argc, VALUE *argv, VALUE self)
15521546
struct generate_json_data data = {
15531547
.buffer = &buffer,
15541548
.vstate = Qfalse,
1555-
.state = &new_state,
1556-
.depth = new_state.depth,
1549+
.state = state,
1550+
.depth = 0,
15571551
.obj = obj,
15581552
.func = generate_json
15591553
};

0 commit comments

Comments
 (0)