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

ruby-changes:51276

From: normal <ko1@a...>
Date: Tue, 22 May 2018 06:21:32 +0900 (JST)
Subject: [ruby-changes:51276] normal:r63481 (trunk): array.c: use ruby_sized_free and SIZED_REALLOC_N

normal	2018-05-22 06:21:23 +0900 (Tue, 22 May 2018)

  New Revision: 63481

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63481

  Log:
    array.c: use ruby_sized_free and SIZED_REALLOC_N
    
    Part of the plan to reduce dependencies on malloc_usable_size
    which costs us speed: https://bugs.ruby-lang.org/issues/10238

  Modified files:
    trunk/array.c
Index: array.c
===================================================================
--- array.c	(revision 63480)
+++ array.c	(revision 63481)
@@ -230,7 +230,7 @@ ary_resize_capa(VALUE ary, long capacity https://github.com/ruby/ruby/blob/trunk/array.c#L230
             MEMCPY((VALUE *)RARRAY(ary)->as.ary, ptr, VALUE, len);
             FL_SET_EMBED(ary);
             ARY_SET_LEN(ary, len);
-	    ruby_xfree((VALUE *)ptr);
+            ruby_sized_xfree((VALUE *)ptr, RARRAY(ary)->as.heap.aux.capa);
         }
     }
 }
@@ -243,7 +243,7 @@ ary_shrink_capa(VALUE ary) https://github.com/ruby/ruby/blob/trunk/array.c#L243
     assert(!ARY_SHARED_P(ary));
     assert(old_capa >= capacity);
     if (old_capa > capacity)
-	REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, capacity);
+        SIZED_REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, capacity, old_capa);
 }
 
 static void

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

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