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

ruby-changes:18560

From: akr <ko1@a...>
Date: Mon, 17 Jan 2011 23:37:11 +0900 (JST)
Subject: [ruby-changes:18560] Ruby:r30583 (trunk): * array.c (rb_ary_times): less MEMCPY calls.

akr	2011-01-17 23:37:05 +0900 (Mon, 17 Jan 2011)

  New Revision: 30583

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

  Log:
    * array.c (rb_ary_times): less MEMCPY calls.

  Modified files:
    trunk/ChangeLog
    trunk/array.c

Index: array.c
===================================================================
--- array.c	(revision 30582)
+++ array.c	(revision 30583)
@@ -2988,7 +2988,7 @@
 rb_ary_times(VALUE ary, VALUE times)
 {
     VALUE ary2, tmp, *ptr, *ptr2;
-    long i, t, len;
+    long t, len;
 
     tmp = rb_check_string_type(times);
     if (!NIL_P(tmp)) {
@@ -3014,8 +3014,15 @@
     ptr = RARRAY_PTR(ary);
     ptr2 = RARRAY_PTR(ary2);
     t = RARRAY_LEN(ary);
-    for (i=0; i<len; i+=t) {
-	MEMCPY(ptr2+i, ptr, VALUE, t);
+    if (0 < t) {
+        MEMCPY(ptr2, ptr, VALUE, t);
+        while (t <= len/2) {
+            MEMCPY(ptr2+t, ptr2, VALUE, t);
+            t *= 2;
+        }
+        if (t < len) {
+            MEMCPY(ptr2+t, ptr2, VALUE, len-t);
+        }
     }
   out:
     OBJ_INFECT(ary2, ary);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30582)
+++ ChangeLog	(revision 30583)
@@ -1,3 +1,7 @@
+Mon Jan 17 23:36:33 2011  Tanaka Akira  <akr@f...>
+
+	* array.c (rb_ary_times): less MEMCPY calls.
+
 Mon Jan 17 22:54:33 2011  Tanaka Akira  <akr@f...>
 
 	* debug.h: parenthesize macro arguments.

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

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