ruby-changes:72693
From: Peter <ko1@a...>
Date: Tue, 26 Jul 2022 22:12:31 +0900 (JST)
Subject: [ruby-changes:72693] efb91ff19b (master): Rename rb_ary_tmp_new to rb_ary_hidden_new
https://git.ruby-lang.org/ruby.git/commit/?id=efb91ff19b From efb91ff19b739b759f40af2673f942e80d212857 Mon Sep 17 00:00:00 2001 From: Peter Zhu <peter@p...> Date: Mon, 25 Jul 2022 10:40:45 -0400 Subject: Rename rb_ary_tmp_new to rb_ary_hidden_new rb_ary_tmp_new suggests that the array is temporary in some way, but that's not true, it just creates an array that's hidden and not on the transient heap. This commit renames it to rb_ary_hidden_new. --- array.c | 10 ++++------ class.c | 6 +++--- compile.c | 22 +++++++++++----------- cont.c | 2 +- enum.c | 4 ++-- ext/fiddle/closure.c | 2 +- ext/openssl/ossl_pkey_ec.c | 2 +- gc.c | 4 ++-- hash.c | 2 +- include/ruby/internal/intern/array.h | 6 +++--- internal/array.h | 2 +- internal/imemo.h | 6 +++--- iseq.c | 4 ++-- load.c | 10 +++++----- marshal.c | 2 +- proc.c | 2 +- ruby.c | 2 +- struct.c | 4 ++-- symbol.c | 4 ++-- thread.c | 14 +++++++------- thread_sync.c | 2 +- vm.c | 2 +- vm_args.c | 6 +++--- 23 files changed, 59 insertions(+), 61 deletions(-) diff --git a/array.c b/array.c index 16c35f7934..af68968a05 100644 --- a/array.c +++ b/array.c @@ -967,7 +967,7 @@ rb_ec_ary_new_from_values(rb_execution_context_t *ec, long n, const VALUE *elts) https://github.com/ruby/ruby/blob/trunk/array.c#L967 } VALUE -rb_ary_tmp_new(long capa) +rb_ary_hidden_new(long capa) { VALUE ary = ary_new(0, capa); rb_ary_transient_heap_evacuate(ary, TRUE); @@ -975,7 +975,7 @@ rb_ary_tmp_new(long capa) https://github.com/ruby/ruby/blob/trunk/array.c#L975 } VALUE -rb_ary_tmp_new_fill(long capa) +rb_ary_hidden_new_fill(long capa) { VALUE ary = ary_new(0, capa); ary_memfill(ary, 0, capa, Qnil); @@ -5101,7 +5101,7 @@ rb_ary_concat_multi(int argc, VALUE *argv, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L5101 } else if (argc > 1) { int i; - VALUE args = rb_ary_tmp_new(argc); + VALUE args = rb_ary_hidden_new(argc); for (i = 0; i < argc; i++) { rb_ary_concat(args, argv[i]); } @@ -6929,8 +6929,6 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L6929 return Qnil; } -#define tmpary(n) rb_ary_tmp_new(n) - /* * Build a ruby array of the corresponding values and yield it to the * associated block. @@ -7625,7 +7623,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L7623 rb_ary_product(int argc, VALUE *argv, VALUE ary) { int n = argc+1; /* How many arrays we're operating on */ - volatile VALUE t0 = tmpary(n); + volatile VALUE t0 = rb_ary_hidden_new(n); volatile VALUE t1 = Qundef; VALUE *arrays = RARRAY_PTR(t0); /* The arrays we're computing the product of */ int *counters = ALLOCV_N(int, t1, n); /* The current position in each one */ diff --git a/class.c b/class.c index 4306b7c0f3..54d9e6e177 100644 --- a/class.c +++ b/class.c @@ -507,7 +507,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig) https://github.com/ruby/ruby/blob/trunk/class.c#L507 VALUE p = RCLASS_SUPER(orig); VALUE orig_origin = RCLASS_ORIGIN(orig); VALUE prev_clone_p = clone; - VALUE origin_stack = rb_ary_tmp_new(2); + VALUE origin_stack = rb_ary_hidden_new(2); VALUE origin[2]; VALUE clone_p = 0; long origin_len; @@ -1250,7 +1250,7 @@ do_include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super https://github.com/ruby/ruby/blob/trunk/class.c#L1250 RCLASS_SET_INCLUDER(iclass, klass); add_subclass = TRUE; if (module != RCLASS_ORIGIN(module)) { - if (!origin_stack) origin_stack = rb_ary_tmp_new(2); + if (!origin_stack) origin_stack = rb_ary_hidden_new(2); VALUE origin[2] = {iclass, RCLASS_ORIGIN(module)}; rb_ary_cat(origin_stack, origin, 2); } @@ -2310,7 +2310,7 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V https://github.com/ruby/ruby/blob/trunk/class.c#L2310 continue; } } - if (NIL_P(missing)) missing = rb_ary_tmp_new(1); + if (NIL_P(missing)) missing = rb_ary_hidden_new(1); rb_ary_push(missing, keyword); } if (!NIL_P(missing)) { diff --git a/compile.c b/compile.c index c17c97adbb..dc8ed45946 100644 --- a/compile.c +++ b/compile.c @@ -313,7 +313,7 @@ static void iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NOD https://github.com/ruby/ruby/blob/trunk/compile.c#L313 LABEL_REF(le); \ LABEL_REF(lc); \ if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) \ - RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_tmp_new(3)); \ + RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_hidden_new(3)); \ rb_ary_push(ISEQ_COMPILE_DATA(iseq)->catch_table_ary, freeze_hide_obj(_e)); \ } while (0) @@ -627,7 +627,7 @@ decl_branch_base(rb_iseq_t *iseq, const NODE *node, const char *type) https://github.com/ruby/ruby/blob/trunk/compile.c#L627 VALUE branches; if (NIL_P(branch_base)) { - branch_base = rb_ary_tmp_new(6); + branch_base = rb_ary_hidden_new(6); rb_hash_aset(structure, key, branch_base); rb_ary_push(branch_base, ID2SYM(rb_intern(type))); rb_ary_push(branch_base, INT2FIX(first_lineno)); @@ -675,7 +675,7 @@ add_trace_branch_coverage(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NODE *n https://github.com/ruby/ruby/blob/trunk/compile.c#L675 long counter_idx; if (NIL_P(branch)) { - branch = rb_ary_tmp_new(6); + branch = rb_ary_hidden_new(6); rb_hash_aset(branches, key, branch); rb_ary_push(branch, ID2SYM(rb_intern(type))); rb_ary_push(branch, INT2FIX(first_lineno)); @@ -1743,7 +1743,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, https://github.com/ruby/ruby/blob/trunk/compile.c#L1743 const NODE *node = args->kw_args; struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq); struct rb_iseq_param_keyword *keyword; - const VALUE default_values = rb_ary_tmp_new(1); + const VALUE default_values = rb_ary_hidden_new(1); const VALUE complex_mark = rb_str_tmp_new(0); int kw = 0, rkw = 0, di = 0, i; @@ -1847,7 +1847,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons https://github.com/ruby/ruby/blob/trunk/compile.c#L1847 if (args->opt_args) { const NODE *node = args->opt_args; LABEL *label; - VALUE labels = rb_ary_tmp_new(1); + VALUE labels = rb_ary_hidden_new(1); VALUE *opt_table; int i = 0, j; @@ -4369,7 +4369,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop https://github.com/ruby/ruby/blob/trunk/compile.c#L4369 if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_ary_len) { /* The literal contains only optimizable elements, or the subarray is long enough */ - VALUE ary = rb_ary_tmp_new(count); + VALUE ary = rb_ary_hidden_new(count); /* Create a hidden array */ for (; count; count--, node = node->nd_next) @@ -4420,7 +4420,7 @@ static int https://github.com/ruby/ruby/blob/trunk/compile.c#L4420 compile_array_1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node) { if (static_literal_node_p(node, iseq)) { - VALUE ary = rb_ary_tmp_new(1); + VALUE ary = rb_ary_hidden_new(1); rb_ary_push(ary, static_literal_value(node, iseq)); OBJ_FREEZE(ary); @@ -4517,7 +4517,7 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth https://github.com/ruby/ruby/blob/trunk/compile.c#L4517 if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_hash_len) { /* The literal contains only optimizable elements, or the subsequence is long enough */ - VALUE ary = rb_ary_tmp_new(count); + VALUE ary = rb_ary_hidden_new(count); /* Create a hidden hash */ for (; count; count--, node = node->nd_next->nd_next) { @@ -12077,7 +12077,7 @@ ibf_dump_iseq_list_i(st_data_t key, st_data_t val, st_data_t ptr) https://github.com/ruby/ruby/blob/trunk/compile.c#L12077 static void ibf_dump_iseq_list(struct ibf_dump *dump, struct ibf_header *header) { - VALUE offset_list = rb_ary_tmp_new(dump->iseq_table->num_entries); + VALUE offset_list = rb_ary_hidden_new(dump->iseq_table->num_entries); struct ibf_dump_iseq_list_arg args; args.dump = dump; @@ -12349,7 +12349,7 @@ ibf_load_object_array(const struct ibf_load *load, const struct ibf_object_heade https://github.com/ruby/ruby/blob/trunk/compile.c#L12349 const long len = (long)ibf_load_small_value(load, &reading_pos); - VALUE ary = header->internal ? rb_ary_tmp_new(len) : rb_ary_new_capa(len); + VALUE ary = header->internal ? rb_ary_hidden_new(len) : rb_ary_new_capa(len); int i; for (i=0; i<len; i++) { @@ -12744,7 +12744,7 @@ static void https://github.com/ruby/ruby/blob/trunk/compile.c#L12744 ibf_dump_object_list(struct ibf_dump *dump, ibf_offset_t *obj_list_offset, unsigned int *obj_list_size) { st_table * (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/