summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2020-05-04 11:33:00 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2020-05-04 13:50:21 -0700
commit5ef019e8afca25442c7c12eea8822d88978141bb (patch)
treee84d811f08f8f7dc6cf420fc4584f6a8b1a977ab /gc.c
parent5c2508060b79b4299a18d05511d3530ad14b1b7a (diff)
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".
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/gc.c b/gc.c
index fb167bf7d5..a3f2de74aa 100644
--- a/gc.c
+++ b/gc.c
@@ -8509,11 +8509,13 @@ gc_compact_stats(rb_objspace_t *objspace)
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);