summaryrefslogtreecommitdiff
path: root/ext/ripper
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2024-01-11 21:27:19 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2024-01-12 21:17:41 +0900
commit52d9e55903b2e72022ba90079cb23c6f2cd03af5 (patch)
tree8e21eed40a4dfe6408053f17387ef60fc8efbb0e /ext/ripper
parentc3b2436154015bab6b94f132b60bdb1fbba02426 (diff)
Statically allocate parser config
Diffstat (limited to 'ext/ripper')
-rw-r--r--ext/ripper/ripper_init.c.tmpl25
1 files changed, 8 insertions, 17 deletions
diff --git a/ext/ripper/ripper_init.c.tmpl b/ext/ripper/ripper_init.c.tmpl
index 5c1a4e5bb5..b2caef2bd5 100644
--- a/ext/ripper/ripper_init.c.tmpl
+++ b/ext/ripper/ripper_init.c.tmpl
@@ -115,10 +115,7 @@ ripper_s_allocate(VALUE klass)
&parser_data_type, r);
#ifdef UNIVERSAL_PARSER
- rb_parser_config_t *config;
- config = rb_ruby_parser_config_new(ruby_xmalloc);
- rb_parser_config_initialize(config);
- r->p = rb_ruby_parser_allocate(config);
+ r->p = rb_parser_params_allocate();
#else
r->p = rb_ruby_ripper_parser_allocate();
#endif
@@ -260,11 +257,11 @@ parser_dedent_string0(VALUE a)
}
static VALUE
-parser_config_free(VALUE a)
+parser_free(VALUE a)
{
- rb_parser_config_t *config = (void *)a;
+ struct parser_params *p = (void *)a;
- rb_ruby_parser_config_free(config);
+ rb_ruby_parser_free(p);
return Qnil;
}
#endif
@@ -283,17 +280,14 @@ static VALUE
parser_dedent_string(VALUE self, VALUE input, VALUE width)
{
struct parser_params *p;
- rb_parser_config_t *config;
struct dedent_string_arg args;
- config = rb_ruby_parser_config_new(ruby_xmalloc);
- rb_parser_config_initialize(config);
- p = rb_ruby_parser_new(config);
+ p = rb_parser_params_new();
args.p = p;
args.input = input;
args.width = width;
- return rb_ensure(parser_dedent_string0, (VALUE)&args, parser_config_free, (VALUE)config);
+ return rb_ensure(parser_dedent_string0, (VALUE)&args, parser_free, (VALUE)p);
}
#else
static VALUE
@@ -530,17 +524,14 @@ static VALUE
ripper_lex_state_name(VALUE self, VALUE state)
{
struct parser_params *p;
- rb_parser_config_t *config;
struct lex_state_name_arg args;
- config = rb_ruby_parser_config_new(ruby_xmalloc);
- rb_parser_config_initialize(config);
- p = rb_ruby_parser_new(config);
+ p = rb_parser_params_new();
args.p = p;
args.state = state;
- return rb_ensure(lex_state_name0, (VALUE)&args, parser_config_free, (VALUE)config);
+ return rb_ensure(lex_state_name0, (VALUE)&args, parser_free, (VALUE)p);
}
#else
static VALUE