Skip to content

Commit 29aaf4a

Browse files
committed
Remove ast_new field from struct rb_parser_config_struct
`ast_new` can be embedded into `rb_ast_new`.
1 parent 5c3d5c7 commit 29aaf4a

File tree

3 files changed

+2
-13
lines changed

3 files changed

+2
-13
lines changed

node.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,9 @@ rb_ast_t *
301301
rb_ast_new(const rb_parser_config_t *config)
302302
{
303303
node_buffer_t *nb = rb_node_buffer_new(config);
304-
rb_ast_t *ast = config->ast_new(nb);
304+
rb_ast_t *ast = (rb_ast_t *)config->calloc(1, sizeof(rb_ast_t));
305305
ast->config = config;
306+
ast->node_buffer = nb;
306307
return ast;
307308
}
308309
#else

ruby_parser.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,6 @@ arg_error(void)
292292
return rb_eArgError;
293293
}
294294

295-
static rb_ast_t *
296-
ast_new(node_buffer_t *nb)
297-
{
298-
rb_ast_t *ast = ruby_xcalloc(1, sizeof(rb_ast_t));
299-
ast->node_buffer = nb;
300-
return ast;
301-
}
302-
303295
static VALUE
304296
static_id2sym(ID id)
305297
{
@@ -348,8 +340,6 @@ static const rb_parser_config_t rb_global_parser_config = {
348340
.nonempty_memcpy = nonempty_memcpy,
349341
.xmalloc_mul_add = rb_xmalloc_mul_add,
350342

351-
.ast_new = ast_new,
352-
353343
.compile_callback = rb_suppress_tracing,
354344
.reg_named_capture_assign = reg_named_capture_assign,
355345

rubyparser.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,8 +1255,6 @@ typedef struct rb_parser_config_struct {
12551255
void *(*nonempty_memcpy)(void *dest, const void *src, size_t t, size_t n);
12561256
void *(*xmalloc_mul_add)(size_t x, size_t y, size_t z);
12571257

1258-
rb_ast_t *(*ast_new)(node_buffer_t *nb);
1259-
12601258
// VALUE rb_suppress_tracing(VALUE (*func)(VALUE), VALUE arg);
12611259
VALUE (*compile_callback)(VALUE (*func)(VALUE), VALUE arg);
12621260
NODE *(*reg_named_capture_assign)(struct parser_params* p, VALUE regexp, const rb_code_location_t *loc);

0 commit comments

Comments
 (0)