Skip to content

Commit efb91ff

Browse files
committed
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.
1 parent 3f70aa6 commit efb91ff

File tree

23 files changed

+59
-61
lines changed

23 files changed

+59
-61
lines changed

array.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -967,15 +967,15 @@ rb_ec_ary_new_from_values(rb_execution_context_t *ec, long n, const VALUE *elts)
967967
}
968968

969969
VALUE
970-
rb_ary_tmp_new(long capa)
970+
rb_ary_hidden_new(long capa)
971971
{
972972
VALUE ary = ary_new(0, capa);
973973
rb_ary_transient_heap_evacuate(ary, TRUE);
974974
return ary;
975975
}
976976

977977
VALUE
978-
rb_ary_tmp_new_fill(long capa)
978+
rb_ary_hidden_new_fill(long capa)
979979
{
980980
VALUE ary = ary_new(0, capa);
981981
ary_memfill(ary, 0, capa, Qnil);
@@ -5101,7 +5101,7 @@ rb_ary_concat_multi(int argc, VALUE *argv, VALUE ary)
51015101
}
51025102
else if (argc > 1) {
51035103
int i;
5104-
VALUE args = rb_ary_tmp_new(argc);
5104+
VALUE args = rb_ary_hidden_new(argc);
51055105
for (i = 0; i < argc; i++) {
51065106
rb_ary_concat(args, argv[i]);
51075107
}
@@ -6929,8 +6929,6 @@ rb_ary_cycle(int argc, VALUE *argv, VALUE ary)
69296929
return Qnil;
69306930
}
69316931

6932-
#define tmpary(n) rb_ary_tmp_new(n)
6933-
69346932
/*
69356933
* Build a ruby array of the corresponding values and yield it to the
69366934
* associated block.
@@ -7625,7 +7623,7 @@ static VALUE
76257623
rb_ary_product(int argc, VALUE *argv, VALUE ary)
76267624
{
76277625
int n = argc+1; /* How many arrays we're operating on */
7628-
volatile VALUE t0 = tmpary(n);
7626+
volatile VALUE t0 = rb_ary_hidden_new(n);
76297627
volatile VALUE t1 = Qundef;
76307628
VALUE *arrays = RARRAY_PTR(t0); /* The arrays we're computing the product of */
76317629
int *counters = ALLOCV_N(int, t1, n); /* The current position in each one */

class.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
507507
VALUE p = RCLASS_SUPER(orig);
508508
VALUE orig_origin = RCLASS_ORIGIN(orig);
509509
VALUE prev_clone_p = clone;
510-
VALUE origin_stack = rb_ary_tmp_new(2);
510+
VALUE origin_stack = rb_ary_hidden_new(2);
511511
VALUE origin[2];
512512
VALUE clone_p = 0;
513513
long origin_len;
@@ -1250,7 +1250,7 @@ do_include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super
12501250
RCLASS_SET_INCLUDER(iclass, klass);
12511251
add_subclass = TRUE;
12521252
if (module != RCLASS_ORIGIN(module)) {
1253-
if (!origin_stack) origin_stack = rb_ary_tmp_new(2);
1253+
if (!origin_stack) origin_stack = rb_ary_hidden_new(2);
12541254
VALUE origin[2] = {iclass, RCLASS_ORIGIN(module)};
12551255
rb_ary_cat(origin_stack, origin, 2);
12561256
}
@@ -2310,7 +2310,7 @@ rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, V
23102310
continue;
23112311
}
23122312
}
2313-
if (NIL_P(missing)) missing = rb_ary_tmp_new(1);
2313+
if (NIL_P(missing)) missing = rb_ary_hidden_new(1);
23142314
rb_ary_push(missing, keyword);
23152315
}
23162316
if (!NIL_P(missing)) {

compile.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ static void iseq_add_setlocal(rb_iseq_t *iseq, LINK_ANCHOR *const seq, const NOD
313313
LABEL_REF(le); \
314314
LABEL_REF(lc); \
315315
if (NIL_P(ISEQ_COMPILE_DATA(iseq)->catch_table_ary)) \
316-
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_tmp_new(3)); \
316+
RB_OBJ_WRITE(iseq, &ISEQ_COMPILE_DATA(iseq)->catch_table_ary, rb_ary_hidden_new(3)); \
317317
rb_ary_push(ISEQ_COMPILE_DATA(iseq)->catch_table_ary, freeze_hide_obj(_e)); \
318318
} while (0)
319319

@@ -627,7 +627,7 @@ decl_branch_base(rb_iseq_t *iseq, const NODE *node, const char *type)
627627
VALUE branches;
628628

629629
if (NIL_P(branch_base)) {
630-
branch_base = rb_ary_tmp_new(6);
630+
branch_base = rb_ary_hidden_new(6);
631631
rb_hash_aset(structure, key, branch_base);
632632
rb_ary_push(branch_base, ID2SYM(rb_intern(type)));
633633
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
675675
long counter_idx;
676676

677677
if (NIL_P(branch)) {
678-
branch = rb_ary_tmp_new(6);
678+
branch = rb_ary_hidden_new(6);
679679
rb_hash_aset(branches, key, branch);
680680
rb_ary_push(branch, ID2SYM(rb_intern(type)));
681681
rb_ary_push(branch, INT2FIX(first_lineno));
@@ -1743,7 +1743,7 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
17431743
const NODE *node = args->kw_args;
17441744
struct rb_iseq_constant_body *const body = ISEQ_BODY(iseq);
17451745
struct rb_iseq_param_keyword *keyword;
1746-
const VALUE default_values = rb_ary_tmp_new(1);
1746+
const VALUE default_values = rb_ary_hidden_new(1);
17471747
const VALUE complex_mark = rb_str_tmp_new(0);
17481748
int kw = 0, rkw = 0, di = 0, i;
17491749

@@ -1847,7 +1847,7 @@ iseq_set_arguments(rb_iseq_t *iseq, LINK_ANCHOR *const optargs, const NODE *cons
18471847
if (args->opt_args) {
18481848
const NODE *node = args->opt_args;
18491849
LABEL *label;
1850-
VALUE labels = rb_ary_tmp_new(1);
1850+
VALUE labels = rb_ary_hidden_new(1);
18511851
VALUE *opt_table;
18521852
int i = 0, j;
18531853

@@ -4369,7 +4369,7 @@ compile_array(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int pop
43694369

43704370
if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_ary_len) {
43714371
/* The literal contains only optimizable elements, or the subarray is long enough */
4372-
VALUE ary = rb_ary_tmp_new(count);
4372+
VALUE ary = rb_ary_hidden_new(count);
43734373

43744374
/* Create a hidden array */
43754375
for (; count; count--, node = node->nd_next)
@@ -4420,7 +4420,7 @@ static int
44204420
compile_array_1(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node)
44214421
{
44224422
if (static_literal_node_p(node, iseq)) {
4423-
VALUE ary = rb_ary_tmp_new(1);
4423+
VALUE ary = rb_ary_hidden_new(1);
44244424
rb_ary_push(ary, static_literal_value(node, iseq));
44254425
OBJ_FREEZE(ary);
44264426

@@ -4517,7 +4517,7 @@ compile_hash(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *node, int meth
45174517

45184518
if ((first_chunk && stack_len == 0 && !node_tmp) || count >= min_tmp_hash_len) {
45194519
/* The literal contains only optimizable elements, or the subsequence is long enough */
4520-
VALUE ary = rb_ary_tmp_new(count);
4520+
VALUE ary = rb_ary_hidden_new(count);
45214521

45224522
/* Create a hidden hash */
45234523
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)
1207712077
static void
1207812078
ibf_dump_iseq_list(struct ibf_dump *dump, struct ibf_header *header)
1207912079
{
12080-
VALUE offset_list = rb_ary_tmp_new(dump->iseq_table->num_entries);
12080+
VALUE offset_list = rb_ary_hidden_new(dump->iseq_table->num_entries);
1208112081

1208212082
struct ibf_dump_iseq_list_arg args;
1208312083
args.dump = dump;
@@ -12349,7 +12349,7 @@ ibf_load_object_array(const struct ibf_load *load, const struct ibf_object_heade
1234912349

1235012350
const long len = (long)ibf_load_small_value(load, &reading_pos);
1235112351

12352-
VALUE ary = header->internal ? rb_ary_tmp_new(len) : rb_ary_new_capa(len);
12352+
VALUE ary = header->internal ? rb_ary_hidden_new(len) : rb_ary_new_capa(len);
1235312353
int i;
1235412354

1235512355
for (i=0; i<len; i++) {
@@ -12744,7 +12744,7 @@ static void
1274412744
ibf_dump_object_list(struct ibf_dump *dump, ibf_offset_t *obj_list_offset, unsigned int *obj_list_size)
1274512745
{
1274612746
st_table *obj_table = dump->current_buffer->obj_table;
12747-
VALUE offset_list = rb_ary_tmp_new(obj_table->num_entries);
12747+
VALUE offset_list = rb_ary_hidden_new(obj_table->num_entries);
1274812748

1274912749
struct ibf_dump_object_list_arg args;
1275012750
args.dump = dump;

cont.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ cont_capture(volatile int *volatile stat)
13161316
entry = cont->ensure_array = ALLOC_N(rb_ensure_entry_t,size+1);
13171317
for (p=th->ec->ensure_list; p; p=p->next) {
13181318
if (!p->entry.marker)
1319-
p->entry.marker = rb_ary_tmp_new(0); /* dummy object */
1319+
p->entry.marker = rb_ary_hidden_new(0); /* dummy object */
13201320
*entry++ = p->entry;
13211321
}
13221322
entry->marker = 0;

enum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ enum_sort_by(VALUE obj)
14871487
ary = rb_ary_new();
14881488
}
14891489
RBASIC_CLEAR_CLASS(ary);
1490-
buf = rb_ary_tmp_new(SORT_BY_BUFSIZE*2);
1490+
buf = rb_ary_hidden_new(SORT_BY_BUFSIZE*2);
14911491
rb_ary_store(buf, SORT_BY_BUFSIZE*2-1, Qnil);
14921492
memo = MEMO_NEW(0, 0, 0);
14931493
data = (struct sort_by_data *)&memo->v1;
@@ -1863,7 +1863,7 @@ rb_nmin_run(VALUE obj, VALUE num, int by, int rev, int ary)
18631863
rb_raise(rb_eArgError, "too big size");
18641864
data.bufmax = data.n * 4;
18651865
data.curlen = 0;
1866-
data.buf = rb_ary_tmp_new(data.bufmax * (by ? 2 : 1));
1866+
data.buf = rb_ary_hidden_new(data.bufmax * (by ? 2 : 1));
18671867
data.limit = Qundef;
18681868
data.cmpfunc = by ? nmin_cmp :
18691869
rb_block_given_p() ? nmin_block_cmp :

ext/fiddle/closure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ with_gvl_callback(void *ptr)
7474
VALUE rbargs = rb_iv_get(self, "@args");
7575
VALUE ctype = rb_iv_get(self, "@ctype");
7676
int argc = RARRAY_LENINT(rbargs);
77-
VALUE params = rb_ary_tmp_new(argc);
77+
VALUE params = rb_ary_hidden_new(argc);
7878
VALUE ret;
7979
VALUE cPointer;
8080
int i, type;

ext/openssl/ossl_pkey_ec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
14621462
"use #mul(bn) form instead");
14631463

14641464
num = RARRAY_LEN(arg1);
1465-
bns_tmp = rb_ary_tmp_new(num);
1465+
bns_tmp = rb_ary_hidden_new(num);
14661466
bignums = ALLOCV_N(const BIGNUM *, tmp_b, num);
14671467
for (i = 0; i < num; i++) {
14681468
VALUE item = RARRAY_AREF(arg1, i);

gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9135,7 +9135,7 @@ rb_gc_register_mark_object(VALUE obj)
91359135
VALUE ary = rb_ary_last(0, 0, ary_ary);
91369136

91379137
if (NIL_P(ary) || RARRAY_LEN(ary) >= MARK_OBJECT_ARY_BUCKET_SIZE) {
9138-
ary = rb_ary_tmp_new(MARK_OBJECT_ARY_BUCKET_SIZE);
9138+
ary = rb_ary_hidden_new(MARK_OBJECT_ARY_BUCKET_SIZE);
91399139
rb_ary_push(ary_ary, ary);
91409140
}
91419141

@@ -14193,7 +14193,7 @@ rb_gcdebug_add_stress_to_class(int argc, VALUE *argv, VALUE self)
1419314193
rb_objspace_t *objspace = &rb_objspace;
1419414194

1419514195
if (!stress_to_class) {
14196-
stress_to_class = rb_ary_tmp_new(argc);
14196+
stress_to_class = rb_ary_hidden_new(argc);
1419714197
}
1419814198
rb_ary_cat(stress_to_class, argv, argc);
1419914199
return self;

hash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3294,7 +3294,7 @@ rb_hash_transform_keys_bang(int argc, VALUE *argv, VALUE hash)
32943294
if (!RHASH_TABLE_EMPTY_P(hash)) {
32953295
long i;
32963296
VALUE new_keys = hash_alloc(0);
3297-
VALUE pairs = rb_ary_tmp_new(RHASH_SIZE(hash) * 2);
3297+
VALUE pairs = rb_ary_hidden_new(RHASH_SIZE(hash) * 2);
32983298
rb_hash_foreach(hash, flatten_i, pairs);
32993299
for (i = 0; i < RARRAY_LEN(pairs); i += 2) {
33003300
VALUE key = RARRAY_AREF(pairs, i), new_key, val;

include/ruby/internal/intern/array.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ VALUE rb_ary_new_from_args(long n, ...);
107107
VALUE rb_ary_new_from_values(long n, const VALUE *elts);
108108

109109
/**
110-
* Allocates a "temporary" array. This is a hidden empty array. Handy on
111-
* occasions.
110+
* Allocates a hidden (no class) empty array.
112111
*
113112
* @param[in] capa Designed capacity of the array.
114113
* @return A hidden, empty array.
115114
* @see rb_obj_hide()
116115
*/
117-
VALUE rb_ary_tmp_new(long capa);
116+
VALUE rb_ary_hidden_new(long capa);
117+
#define rb_ary_tmp_new rb_ary_hidden_new
118118

119119
/**
120120
* Destroys the given array for no reason.

0 commit comments

Comments
 (0)