Skip to content

Commit

Permalink
Remove ast_new field from struct rb_parser_config_struct
Browse files Browse the repository at this point in the history
`ast_new` can be embedded into `rb_ast_new`.
  • Loading branch information
yui-knk committed Apr 28, 2024
1 parent ddd8da4 commit 3a3b7d8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
3 changes: 2 additions & 1 deletion node.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,9 @@ rb_ast_t *
rb_ast_new(const rb_parser_config_t *config)
{
node_buffer_t *nb = rb_node_buffer_new(config);
rb_ast_t *ast = config->ast_new(nb);
rb_ast_t *ast = (rb_ast_t *)config->calloc(1, sizeof(rb_ast_t));
ast->config = config;
ast->node_buffer = nb;
return ast;
}
#else
Expand Down
10 changes: 0 additions & 10 deletions ruby_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,6 @@ arg_error(void)
return rb_eArgError;
}

static rb_ast_t *
ast_new(node_buffer_t *nb)
{
rb_ast_t *ast = ruby_xcalloc(1, sizeof(rb_ast_t));
ast->node_buffer = nb;
return ast;
}

static VALUE
static_id2sym(ID id)
{
Expand Down Expand Up @@ -348,8 +340,6 @@ static const rb_parser_config_t rb_global_parser_config = {
.nonempty_memcpy = nonempty_memcpy,
.xmalloc_mul_add = rb_xmalloc_mul_add,

.ast_new = ast_new,

.compile_callback = rb_suppress_tracing,
.reg_named_capture_assign = reg_named_capture_assign,

Expand Down
2 changes: 0 additions & 2 deletions rubyparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,6 @@ typedef struct rb_parser_config_struct {
void *(*nonempty_memcpy)(void *dest, const void *src, size_t t, size_t n);
void *(*xmalloc_mul_add)(size_t x, size_t y, size_t z);

rb_ast_t *(*ast_new)(node_buffer_t *nb);

// VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
VALUE (*compile_callback)(VALUE (*func)(VALUE), VALUE arg);
NODE *(*reg_named_capture_assign)(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc);
Expand Down

0 comments on commit 3a3b7d8

Please sign in to comment.