зеркало из https://github.com/github/ruby.git
vm_insnhelper.c: avoid intermediate array
* vm_insnhelper.c (vm_expandarray): get rid of creating intermediate Array object when conversion failed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
fe18a62347
Коммит
27db7101c6
|
@ -1237,16 +1237,20 @@ vm_expandarray(rb_control_frame_t *cfp, VALUE ary, rb_num_t num, int flag)
|
|||
VALUE *base = cfp->sp;
|
||||
const VALUE *ptr;
|
||||
rb_num_t len;
|
||||
const VALUE obj = ary;
|
||||
|
||||
if (!RB_TYPE_P(ary, T_ARRAY)) {
|
||||
ary = rb_ary_to_ary(ary);
|
||||
if (!RB_TYPE_P(ary, T_ARRAY) && NIL_P(ary = rb_check_array_type(ary))) {
|
||||
ary = obj;
|
||||
ptr = &ary;
|
||||
len = 1;
|
||||
}
|
||||
else {
|
||||
ptr = RARRAY_CONST_PTR(ary);
|
||||
len = (rb_num_t)RARRAY_LEN(ary);
|
||||
}
|
||||
|
||||
cfp->sp += space_size;
|
||||
|
||||
ptr = RARRAY_CONST_PTR(ary);
|
||||
len = (rb_num_t)RARRAY_LEN(ary);
|
||||
|
||||
if (flag & 0x02) {
|
||||
/* post: ..., nil ,ary[-1], ..., ary[0..-num] # top */
|
||||
rb_num_t i = 0, j;
|
||||
|
|
Загрузка…
Ссылка в новой задаче