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

ruby-changes:57570

From: Aaron <ko1@a...>
Date: Fri, 6 Sep 2019 02:30:08 +0900 (JST)
Subject: [ruby-changes:57570] 01aa2462b5 (master): lazily allocate the mark array

https://git.ruby-lang.org/ruby.git/commit/?id=01aa2462b5

From 01aa2462b5abb6833af83f47961932ebca587573 Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Wed, 4 Sep 2019 16:21:05 -0700
Subject: lazily allocate the mark array


diff --git a/node.c b/node.c
index 8dff1d2..7ebc1cb 100644
--- a/node.c
+++ b/node.c
@@ -1149,7 +1149,7 @@ rb_node_buffer_new(void) https://github.com/ruby/ruby/blob/trunk/node.c#L1149
     node_buffer_t *nb = xmalloc(sizeof(node_buffer_t) + (bucket_size * 2));
     init_node_buffer_list(&nb->unmarkable, (node_buffer_elem_t*)&nb[1]);
     init_node_buffer_list(&nb->markable, (node_buffer_elem_t*)((size_t)nb->unmarkable.head + bucket_size));
-    nb->mark_ary = rb_ary_tmp_new(0);
+    nb->mark_ary = Qnil;
     return nb;
 }
 
@@ -1222,9 +1222,7 @@ rb_ast_t * https://github.com/ruby/ruby/blob/trunk/node.c#L1222
 rb_ast_new(void)
 {
     node_buffer_t *nb = rb_node_buffer_new();
-    VALUE mark_ary = nb->mark_ary;
     rb_ast_t *ast = (rb_ast_t *)rb_imemo_new(imemo_ast, 0, 0, 0, (VALUE)nb);
-    RB_OBJ_WRITTEN(ast, Qnil, mark_ary);
     return ast;
 }
 
@@ -1337,5 +1335,8 @@ rb_ast_dispose(rb_ast_t *ast) https://github.com/ruby/ruby/blob/trunk/node.c#L1335
 void
 rb_ast_add_mark_object(rb_ast_t *ast, VALUE obj)
 {
+    if (NIL_P(ast->node_buffer->mark_ary)) {
+        RB_OBJ_WRITE(ast, &ast->node_buffer->mark_ary, rb_ary_tmp_new(0));
+    }
     rb_ary_push(ast->node_buffer->mark_ary, obj);
 }
-- 
cgit v0.10.2


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

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