ruby-changes:49817
From: nobu <ko1@a...>
Date: Fri, 19 Jan 2018 00:48:59 +0900 (JST)
Subject: [ruby-changes:49817] nobu:r61936 (trunk): compile.c: use ALLOCV_N
nobu 2018-01-19 00:48:55 +0900 (Fri, 19 Jan 2018) New Revision: 61936 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61936 Log: compile.c: use ALLOCV_N * compile.c (ibf_dump_object_list): allocate known-size array by ALLOCV_N instead of rb_ary_tmp_new. Modified files: trunk/compile.c Index: compile.c =================================================================== --- compile.c (revision 61935) +++ compile.c (revision 61936) @@ -9295,21 +9295,23 @@ ibf_load_object(const struct ibf_load *l https://github.com/ruby/ruby/blob/trunk/compile.c#L9295 static void ibf_dump_object_list(struct ibf_dump *dump, struct ibf_header *header) { - VALUE list = rb_ary_tmp_new(RARRAY_LEN(dump->obj_list)); + VALUE listv; + ibf_offset_t *list = ALLOCV_N(ibf_offset_t, listv, RARRAY_LEN(dump->obj_list)); int i, size; for (i=0; i<RARRAY_LEN(dump->obj_list); i++) { VALUE obj = RARRAY_AREF(dump->obj_list, i); ibf_offset_t offset = lbf_dump_object_object(dump, obj); - rb_ary_push(list, UINT2NUM(offset)); + list[i] = offset; } size = i; header->object_list_offset = ibf_dump_pos(dump); for (i=0; i<size; i++) { - ibf_offset_t offset = NUM2UINT(RARRAY_AREF(list, i)); + ibf_offset_t offset = list[i]; IBF_WV(offset); } + ALLOCV_END(listv); header->object_list_size = size; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/