summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2024-08-11 12:58:57 +0200
committerJean Boussier <[email protected]>2024-08-11 15:04:35 +0200
commitca5b7276c668f595b8348822fc61a90cd5b9710f (patch)
treead4209ee97d9f267be9be09790230c8ae80891ff /compile.c
parent1fd0a1b4ceef29a5aade5e1d896dca5b74258e6f (diff)
compile.c: don't allocate empty default values list
It just wastes memory.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11361
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index dfeb7ed284..e41f27daf9 100644
--- a/compile.c
+++ b/compile.c
@@ -1985,7 +1985,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
keyword->required_num = rkw;
keyword->table = &body->local_table[keyword->bits_start - keyword->num];
- {
+ if (RARRAY_LEN(default_values)) {
VALUE *dvs = ALLOC_N(VALUE, RARRAY_LEN(default_values));
for (i = 0; i < RARRAY_LEN(default_values); i++) {
@@ -12769,7 +12769,7 @@ ibf_load_param_keyword(const struct ibf_load *load, ibf_offset_t param_keyword_o
struct rb_iseq_param_keyword *kw = IBF_R(param_keyword_offset, struct rb_iseq_param_keyword, 1);
ID *ids = IBF_R(kw->table, ID, kw->num);
int dv_num = kw->num - kw->required_num;
- VALUE *dvs = IBF_R(kw->default_values, VALUE, dv_num);
+ VALUE *dvs = dv_num ? IBF_R(kw->default_values, VALUE, dv_num) : NULL;
int i;
for (i=0; i<kw->num; i++) {