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

ruby-changes:61008

From: Aaron <ko1@a...>
Date: Tue, 5 May 2020 05:50:46 +0900 (JST)
Subject: [ruby-changes:61008] 5ef019e8af (master): Output compaction stats in one loop / eliminate 0 counts

https://git.ruby-lang.org/ruby.git/commit/?id=5ef019e8af

From 5ef019e8afca25442c7c12eea8822d88978141bb Mon Sep 17 00:00:00 2001
From: Aaron Patterson <tenderlove@r...>
Date: Mon, 4 May 2020 11:33:00 -0700
Subject: Output compaction stats in one loop / eliminate 0 counts

We only need to loop `T_MASK` times once.  Also, not every value between
0 and `T_MASK` is an actual Ruby type.  Before this change, some
integers were being added to the result hash even though they aren't
actual types.  This patch omits considered / moved entries that total 0,
cleaning up the result hash and eliminating these "fake types".

diff --git a/gc.c b/gc.c
index fb167bf..a3f2de7 100644
--- a/gc.c
+++ b/gc.c
@@ -8509,11 +8509,13 @@ gc_compact_stats(rb_objspace_t *objspace) https://github.com/ruby/ruby/blob/trunk/gc.c#L8509
     VALUE moved = rb_hash_new();
 
     for (i=0; i<T_MASK; i++) {
-        rb_hash_aset(considered, type_sym(i), SIZET2NUM(objspace->rcompactor.considered_count_table[i]));
-    }
+        if(objspace->rcompactor.considered_count_table[i]) {
+            rb_hash_aset(considered, type_sym(i), SIZET2NUM(objspace->rcompactor.considered_count_table[i]));
+        }
 
-    for (i=0; i<T_MASK; i++) {
-        rb_hash_aset(moved, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_count_table[i]));
+        if(objspace->rcompactor.moved_count_table[i]) {
+            rb_hash_aset(moved, type_sym(i), SIZET2NUM(objspace->rcompactor.moved_count_table[i]));
+        }
     }
 
     rb_hash_aset(h, ID2SYM(rb_intern("considered")), considered);
-- 
cgit v0.10.2


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

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