Skip to content

Commit

Permalink
Let empty arrays being flattened not alloc additional state
Browse files Browse the repository at this point in the history
  • Loading branch information
methodmissing committed Sep 10, 2019
1 parent 91ee958 commit 602fe51
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -5123,6 +5123,8 @@ flatten(VALUE ary, int level, int *modified)
st_table *memo;
st_data_t id;

if (RARRAY_LEN(ary) == 0) return ary_new(0, 0);

stack = ary_new(0, ARY_DEFAULT_SIZE);
result = ary_new(0, RARRAY_LEN(ary));
memo = st_init_numtable();
Expand Down

0 comments on commit 602fe51

Please sign in to comment.