From ad0ef29da7ac37b978c281b1e0070fbb6afbe2e6 Mon Sep 17 00:00:00 2001 From: ko1 Date: Mon, 26 Aug 2013 05:47:27 +0000 Subject: [PATCH] * array.c (rb_ary_splice): use RARRAY_PTR_USE() without WB because there are not new relations. * enum.c (enum_sort_by): ditto. * struct.c (setup_struct): use RARRAY_RAWPTR(). * vm_eval.c (yield_under): ditto. * ext/pathname/pathname.c (path_entries): use RARRAY_AREF(). * ext/pathname/pathname.c (path_s_glob): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 15 +++++++++++++++ array.c | 5 +++-- enum.c | 5 +++-- ext/pathname/pathname.c | 4 ++-- struct.c | 4 ++-- vm_eval.c | 2 +- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24b4c06e08..00bbc9d7fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +Mon Aug 26 14:44:26 2013 Koichi Sasada + + * array.c (rb_ary_splice): use RARRAY_PTR_USE() without WB because + there are not new relations. + + * enum.c (enum_sort_by): ditto. + + * struct.c (setup_struct): use RARRAY_RAWPTR(). + + * vm_eval.c (yield_under): ditto. + + * ext/pathname/pathname.c (path_entries): use RARRAY_AREF(). + + * ext/pathname/pathname.c (path_s_glob): ditto. + Mon Aug 26 13:11:10 2013 Kazuhiro NISHIYAMA * array.c (ary_ensure_room_for_push): fix typo in r42658. diff --git a/array.c b/array.c index c5105c0368..20d0fa101a 100644 --- a/array.c +++ b/array.c @@ -1545,8 +1545,9 @@ rb_ary_splice(VALUE ary, long beg, long len, VALUE rpl) } if (len != rlen) { - MEMMOVE(RARRAY_PTR(ary) + beg + rlen, RARRAY_PTR(ary) + beg + len, - VALUE, RARRAY_LEN(ary) - (beg + len)); + RARRAY_PTR_USE(ary, ptr, + MEMMOVE(ptr + beg + rlen, ptr + beg + len, + VALUE, RARRAY_LEN(ary) - (beg + len))); ARY_SET_LEN(ary, alen); } if (rlen > 0) { diff --git a/enum.c b/enum.c index 8dd24514b5..e977dedd76 100644 --- a/enum.c +++ b/enum.c @@ -944,8 +944,9 @@ enum_sort_by(VALUE obj) rb_ary_concat(ary, buf); } if (RARRAY_LEN(ary) > 2) { - ruby_qsort(RARRAY_PTR(ary), RARRAY_LEN(ary)/2, 2*sizeof(VALUE), - sort_by_cmp, (void *)ary); + RARRAY_PTR_USE(ary, ptr, + ruby_qsort(ptr, RARRAY_LEN(ary)/2, 2*sizeof(VALUE), + sort_by_cmp, (void *)ary)); } if (RBASIC(ary)->klass) { rb_raise(rb_eRuntimeError, "sort_by reentered"); diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 884bd4a821..8205b3c830 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -997,7 +997,7 @@ path_s_glob(int argc, VALUE *argv, VALUE klass) ary = rb_funcall2(rb_cDir, rb_intern("glob"), n, args); ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary"); for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; + VALUE elt = RARRAY_AREF(ary, i); elt = rb_class_new_instance(1, &elt, klass); rb_ary_store(ary, i, elt); } @@ -1057,7 +1057,7 @@ path_entries(VALUE self) ary = rb_funcall(rb_cDir, rb_intern("entries"), 1, str); ary = rb_convert_type(ary, T_ARRAY, "Array", "to_ary"); for (i = 0; i < RARRAY_LEN(ary); i++) { - VALUE elt = RARRAY_PTR(ary)[i]; + VALUE elt = RARRAY_AREF(ary, i); elt = rb_class_new_instance(1, &elt, klass); rb_ary_store(ary, i, elt); } diff --git a/struct.c b/struct.c index ebb301701c..bd1d0d04fe 100644 --- a/struct.c +++ b/struct.c @@ -197,7 +197,7 @@ new_struct(VALUE name, VALUE super) static VALUE setup_struct(VALUE nstr, VALUE members) { - VALUE *ptr_members; + const VALUE *ptr_members; long i, len; OBJ_FREEZE(members); @@ -207,7 +207,7 @@ setup_struct(VALUE nstr, VALUE members) rb_define_singleton_method(nstr, "new", rb_class_new_instance, -1); rb_define_singleton_method(nstr, "[]", rb_class_new_instance, -1); rb_define_singleton_method(nstr, "members", rb_struct_s_members_m, 0); - ptr_members = RARRAY_PTR(members); + ptr_members = RARRAY_RAWPTR(members); len = RARRAY_LEN(members); for (i=0; i< len; i++) { ID id = SYM2ID(ptr_members[i]); diff --git a/vm_eval.c b/vm_eval.c index a7f6c70b10..99a98d5cf5 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1510,7 +1510,7 @@ yield_under(VALUE under, VALUE self, VALUE values) return vm_yield_with_cref(th, 1, &self, cref); } else { - return vm_yield_with_cref(th, RARRAY_LENINT(values), RARRAY_PTR(values), cref); + return vm_yield_with_cref(th, RARRAY_LENINT(values), RARRAY_RAWPTR(values), cref); } }