[前][次][番号順一覧][スレッド一覧]

ruby-changes:30053

From: ko1 <ko1@a...>
Date: Mon, 22 Jul 2013 13:00:25 +0900 (JST)
Subject: [ruby-changes:30053] ko1:r42105 (trunk): * array.c (ary_memfill): added.

ko1	2013-07-22 13:00:12 +0900 (Mon, 22 Jul 2013)

  New Revision: 42105

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42105

  Log:
    * array.c (ary_memfill): added.
    * array.c (rb_ary_initialize): use ary_memfill().
    * array.c (rb_ary_fill): ditto.
    * array.c (rb_ary_slice_bang): use RARRAY_RAWPTR() because
      this code creates no new references.

  Modified files:
    trunk/ChangeLog
    trunk/array.c

Index: array.c
===================================================================
--- array.c	(revision 42104)
+++ array.c	(revision 42105)
@@ -102,6 +102,15 @@ memfill(register VALUE *mem, register lo https://github.com/ruby/ruby/blob/trunk/array.c#L102
 }
 
 static void
+ary_memfill(VALUE ary, long beg, long size, VALUE val)
+{
+    RARRAY_PTR_USE(ary, ptr, {
+	memfill(ptr + beg, size, val);
+	OBJ_WRITTEN(ary, Qundef, val);
+    });
+}
+
+static void
 ary_memcpy(VALUE ary, long beg, long argc, const VALUE *argv)
 {
 #if 1
@@ -787,10 +796,7 @@ rb_ary_initialize(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/array.c#L796
 	}
     }
     else {
-	RARRAY_PTR_USE(ary, ptr, {
-	    memfill((VALUE *)ptr, len, val);
-	});
-	OBJ_WRITTEN(ary, Qundef, val);
+	ary_memfill(ary, 0, len, val);
 	ARY_SET_LEN(ary, len);
     }
     return ary;
@@ -2999,7 +3005,7 @@ rb_ary_slice_bang(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/array.c#L3005
 	    len = orig_len - pos;
 	}
 	if (len == 0) return rb_ary_new2(0);
-	arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos);
+	arg2 = rb_ary_new4(len, RARRAY_RAWPTR(ary)+pos);
 	RBASIC_SET_CLASS(arg2, rb_obj_class(ary));
 	rb_ary_splice(ary, pos, len, Qundef);
 	return arg2;
@@ -3372,7 +3378,6 @@ rb_ary_fill(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L3378
 {
     VALUE item, arg1, arg2;
     long beg = 0, end = 0, len = 0;
-    VALUE *p;
     int block_p = FALSE;
 
     if (rb_block_given_p()) {
@@ -3429,8 +3434,7 @@ rb_ary_fill(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/array.c#L3434
 	}
     }
     else {
-	p = RARRAY_PTR(ary) + beg;
-	memfill(p, len, item);
+	ary_memfill(ary, beg, len, item);
     }
     return ary;
 }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42104)
+++ ChangeLog	(revision 42105)
@@ -1,3 +1,14 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon Jul 22 12:58:18 2013  Koichi Sasada  <ko1@a...>
+
+	* array.c (ary_memfill): added.
+
+	* array.c (rb_ary_initialize): use ary_memfill().
+
+	* array.c (rb_ary_fill): ditto.
+
+	* array.c (rb_ary_slice_bang): use RARRAY_RAWPTR() because
+	  this code creates no new references.
+
 Mon Jul 22 10:09:46 2013  Koichi Sasada  <ko1@a...>
 
 	* gc.c (gc_slot_sweep): need to add empty RVALUE as freeobj.

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]