Skip to content

Commit 73060a6

Browse files
authored
Remove unnecessary freeing functions (#40)
`rbs_node_destroy`, `rbs_hash_free`, `rbs_node_list_free` are only calling each other recursively without any real freeing logic. This is the result of previous efforts to allocate all nodes on the arena. So we don't need these functions anymore. Discovered while working on #41
1 parent da91a88 commit 73060a6

File tree

6 files changed

+66
-868
lines changed

6 files changed

+66
-868
lines changed

ext/rbs_extension/main.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,7 @@ static VALUE parse_type_try(VALUE a) {
123123
arg->encoding
124124
);
125125

126-
127-
VALUE ruby_ast = rbs_struct_to_ruby_value(ctx, type);
128-
rbs_node_destroy((rbs_node_t *) type);
129-
return ruby_ast;
126+
return rbs_struct_to_ruby_value(ctx, type);
130127
}
131128

132129
static rbs_lexer_t *alloc_lexer_from_buffer(rbs_allocator_t *allocator, VALUE string, rb_encoding *encoding, int start_pos, int end_pos) {
@@ -213,9 +210,7 @@ static VALUE parse_method_type_try(VALUE a) {
213210
arg->encoding
214211
);
215212

216-
VALUE ruby_ast = rbs_struct_to_ruby_value(ctx, (rbs_node_t *) method_type);
217-
rbs_node_destroy((rbs_node_t *) method_type);
218-
return ruby_ast;
213+
return rbs_struct_to_ruby_value(ctx, (rbs_node_t *) method_type);
219214
}
220215

221216
static VALUE rbsparser_parse_method_type(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos, VALUE variables, VALUE require_eof) {
@@ -254,9 +249,7 @@ static VALUE parse_signature_try(VALUE a) {
254249
arg->encoding
255250
);
256251

257-
VALUE ruby_ast = rbs_struct_to_ruby_value(ctx, (rbs_node_t *) signature);
258-
rbs_node_destroy((rbs_node_t *) signature);
259-
return ruby_ast;
252+
return rbs_struct_to_ruby_value(ctx, (rbs_node_t *) signature);
260253
}
261254

262255
static VALUE rbsparser_parse_signature(VALUE self, VALUE buffer, VALUE start_pos, VALUE end_pos) {

include/rbs/ast.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,4 @@ rbs_types_union_t *rbs_types_union_new(rbs_allocator_t *allocator, rbs_location_
685685
rbs_types_untyped_function_t *rbs_types_untyped_function_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_node_t *return_type);
686686
rbs_types_variable_t *rbs_types_variable_new(rbs_allocator_t *allocator, rbs_location_t *location, rbs_ast_symbol_t *name);
687687

688-
void rbs_node_destroy(rbs_node_t *any_node);
689-
690688
#endif

0 commit comments

Comments
 (0)