ruby-changes:61972
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:22 +0900 (JST)
Subject: [ruby-changes:61972] 2d6f8db3d6 (master): add spaces [ci skip]
https://git.ruby-lang.org/ruby.git/commit/?id=2d6f8db3d6 From 2d6f8db3d60e0c54cc51d2bd5ed6b86af7ef15ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Fri, 12 Jun 2020 11:04:46 +0900 Subject: add spaces [ci skip] diff --git a/array.c b/array.c index 2d16287..3bbc094 100644 --- a/array.c +++ b/array.c @@ -1573,15 +1573,18 @@ make_room_for_unshift(VALUE ary, const VALUE *head, VALUE *sharedp, int argc, lo https://github.com/ruby/ruby/blob/trunk/array.c#L1573 { if (head - sharedp < argc) { long room = capa - len - argc; + room -= room >> 4; MEMMOVE((VALUE *)sharedp + argc + room, head, VALUE, len); head = sharedp + argc + room; } ARY_SET_PTR(ary, head - argc); assert(ARY_SHARED_ROOT_OCCUPIED(ARY_SHARED_ROOT(ary))); + ary_verify(ary); return ARY_SHARED_ROOT(ary); } + static VALUE ary_modify_for_unshift(VALUE ary, int argc) { @@ -1617,11 +1620,13 @@ ary_modify_for_unshift(VALUE ary, int argc) https://github.com/ruby/ruby/blob/trunk/array.c#L1620 return ary; } } + static VALUE ary_ensure_room_for_unshift(VALUE ary, int argc) { long len = RARRAY_LEN(ary); long new_len = len + argc; + if (len > ARY_MAX_SIZE - argc) { rb_raise(rb_eIndexError, "index %ld too big", new_len); } @@ -1631,6 +1636,7 @@ ary_ensure_room_for_unshift(VALUE ary, int argc) https://github.com/ruby/ruby/blob/trunk/array.c#L1636 else { VALUE shared_root = ARY_SHARED_ROOT(ary); long capa = RARRAY_LEN(shared_root); + if (! ARY_SHARED_ROOT_OCCUPIED(shared_root)) { return ary_modify_for_unshift(ary, argc); } @@ -1638,9 +1644,10 @@ ary_ensure_room_for_unshift(VALUE ary, int argc) https://github.com/ruby/ruby/blob/trunk/array.c#L1644 return ary_modify_for_unshift(ary, argc); } else { - rb_ary_modify_check(ary); const VALUE * head = RARRAY_CONST_PTR_TRANSIENT(ary); void *sharedp = (void *)RARRAY_CONST_PTR_TRANSIENT(shared_root); + + rb_ary_modify_check(ary); return make_room_for_unshift(ary, head, sharedp, argc, capa, len); } } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/