summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-23 09:42:18 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-23 09:42:18 +0000
commit5bcdc68c6e41b1c2b1cb5ce82c64036df80e48de (patch)
treeeae2366c18feff70ed63fae2e596bc4f203f2b6e /array.c
parentf539e9cbf3e50f5d9be45a0e4c23366bb3e4e6ef (diff)
* array.c (ary_make_shared): shared ary as shady. Need more effort to
make it normal object. * array.c (rb_ary_modify): use RARRAY_PTR_USE() without WB because there are not new relations. * array.c (ary_ensure_room_for_unshift): use RARRAY_RAWPTR() because there are not new relations. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/array.c b/array.c
index ecfbc64..44cd445 100644
--- a/array.c
+++ b/array.c
@@ -328,7 +328,9 @@ rb_ary_modify(VALUE ary)
FL_UNSET_SHARED(ary);
ARY_SET_PTR(ary, RARRAY_RAWPTR(shared));
ARY_SET_CAPA(ary, RARRAY_LEN(shared));
- MEMMOVE(RARRAY_PTR(ary), RARRAY_PTR(ary)+shift, VALUE, len);
+ RARRAY_PTR_USE(ary, ptr, {
+ MEMMOVE(ptr, ptr+shift, VALUE, len);
+ });
FL_SET_EMBED(shared);
rb_ary_decrement_share(shared);
}
@@ -571,12 +573,12 @@ ary_make_shared(VALUE ary)
return ary;
}
else {
- NEWOBJ_OF(shared, struct RArray, 0, T_ARRAY | (RGENGC_WB_PROTECTED_ARRAY ? FL_WB_PROTECTED : 0));
+ NEWOBJ_OF(shared, struct RArray, 0, T_ARRAY); /* keep shared ary as shady */
FL_UNSET_EMBED(shared);
ARY_SET_LEN((VALUE)shared, ARY_CAPA(ary));
- ARY_SET_PTR((VALUE)shared, RARRAY_PTR(ary));
- rb_mem_clear(RARRAY_PTR(shared) + RARRAY_LEN(ary), ARY_CAPA(ary) - RARRAY_LEN(ary));
+ ARY_SET_PTR((VALUE)shared, RARRAY_RAWPTR(ary));
+ ary_mem_clear((VALUE)shared, RARRAY_LEN(ary), ARY_CAPA(ary) - RARRAY_LEN(ary));
FL_SET_SHARED_ROOT(shared);
ARY_SET_SHARED_NUM((VALUE)shared, 1);
FL_SET_SHARED(ary);
@@ -1073,14 +1075,14 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
long len = RARRAY_LEN(ary);
long new_len = len + argc;
long capa;
- VALUE *head, *sharedp;
+ const VALUE *head, *sharedp;
if (ARY_SHARED_P(ary)) {
VALUE shared = ARY_SHARED(ary);
capa = RARRAY_LEN(shared);
if (ARY_SHARED_OCCUPIED(shared) && capa > new_len) {
- head = RARRAY_PTR(ary);
- sharedp = RARRAY_PTR(shared);
+ head = RARRAY_RAWPTR(ary);
+ sharedp = RARRAY_RAWPTR(shared);
goto makeroom_if_need;
}
}
@@ -1097,7 +1099,7 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
capa = ARY_CAPA(ary);
ary_make_shared(ary);
- head = sharedp = RARRAY_PTR(ary);
+ head = sharedp = RARRAY_RAWPTR(ary);
goto makeroom;
makeroom_if_need:
if (head - sharedp < argc) {
@@ -1105,7 +1107,7 @@ ary_ensure_room_for_unshift(VALUE ary, int argc)
makeroom:
room = capa - new_len;
room -= room >> 4;
- MEMMOVE(sharedp + argc + room, head, VALUE, len);
+ MEMMOVE((VALUE *)sharedp + argc + room, head, VALUE, len);
head = sharedp + argc + room;
}
ARY_SET_PTR(ary, head - argc);