Skip to content

Commit d7964f8

Browse files
etiennebarriebyroot
authored andcommitted
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 873b29e commit d7964f8

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
@@ -1539,12 +1539,6 @@ static VALUE cState_generate_new(int argc, VALUE *argv, VALUE self)
15391539

15401540
GET_STATE(self);
15411541

1542-
JSON_Generator_State new_state;
1543-
MEMCPY(&new_state, state, JSON_Generator_State, 1);
1544-
1545-
// FIXME: depth shouldn't be part of JSON_Generator_State, as that prevents it from being used concurrently.
1546-
new_state.depth = 0;
1547-
15481542
char stack_buffer[FBUFFER_STACK_SIZE];
15491543
FBuffer buffer = {
15501544
.io = RTEST(io) ? io : Qfalse,
@@ -1554,8 +1548,8 @@ static VALUE cState_generate_new(int argc, VALUE *argv, VALUE self)
15541548
struct generate_json_data data = {
15551549
.buffer = &buffer,
15561550
.vstate = Qfalse,
1557-
.state = &new_state,
1558-
.depth = new_state.depth,
1551+
.state = state,
1552+
.depth = 0,
15591553
.obj = obj,
15601554
.func = generate_json
15611555
};

0 commit comments

Comments
 (0)