From c3ab946e86134e05a81c0587ef1d5cdf1de4492f Mon Sep 17 00:00:00 2001 From: yui-knk Date: Wed, 15 Nov 2023 08:57:49 +0900 Subject: [PATCH] `ObjectSpace.count_nodes` doesn't count nodes Node has not been managed by GC from Ruby 2.5. Therefore these codes are not needed. If ObjectSpace depends on Node, it needs to update the file when node type is updated. Delete node related codes to avoid such update. --- ext/objspace/objspace.c | 143 +--------------------------------------- 1 file changed, 1 insertion(+), 142 deletions(-) diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index ae869a3ed4..0a7896d5c6 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -19,7 +19,6 @@ #include "internal/hash.h" #include "internal/imemo.h" #include "internal/sanitizers.h" -#include "node.h" #include "ruby/io.h" #include "ruby/re.h" #include "ruby/st.h" @@ -337,17 +336,6 @@ count_symbols(int argc, VALUE *argv, VALUE os) return hash; } -static void -cn_i(VALUE v, void *n) -{ - size_t *nodes = (size_t *)n; - - if (BUILTIN_TYPE(v) == T_NODE) { - size_t s = nd_type((NODE *)v); - nodes[s]++; - } -} - /* * call-seq: * ObjectSpace.count_nodes([result_hash]) -> hash @@ -374,136 +362,7 @@ cn_i(VALUE v, void *n) static VALUE count_nodes(int argc, VALUE *argv, VALUE os) { - size_t nodes[NODE_LAST+1]; - enum node_type i; - VALUE hash = setup_hash(argc, argv); - - for (i = 0; i <= NODE_LAST; i++) { - nodes[i] = 0; - } - - each_object_with_flags(cn_i, &nodes[0]); - - for (i=0; i