aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-01 14:06:42 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-09-01 14:06:42 +0900
commit4c040fe8503d664dce46bf2fd9d2cfe8be6fbf41 (patch)
tree62f16900e8d0fe0ba7afc76643bf67dd5c1d814c /iseq.c
parent1fbc8cdf0686657c12cc9014cb4714730adc2ec6 (diff)
downloadruby-4c040fe8503d664dce46bf2fd9d2cfe8be6fbf41.tar.gz
Copy compile options from AST directly without intermediate Hash
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/iseq.c b/iseq.c
index 3b91317d33..db7303aac5 100644
--- a/iseq.c
+++ b/iseq.c
@@ -747,20 +747,15 @@ set_compile_option_from_hash(rb_compile_option_t *option, VALUE opt)
#undef SET_COMPILE_OPTION_NUM
}
-static VALUE
-make_compile_option_from_ast(const rb_ast_body_t *ast)
+static rb_compile_option_t *
+set_compile_option_from_ast(rb_compile_option_t *option, const rb_ast_body_t *ast)
{
- VALUE opt = rb_obj_hide(rb_ident_hash_new());
- if (ast->frozen_string_literal >= 0) rb_hash_aset(opt, rb_sym_intern_ascii_cstr("frozen_string_literal"), RBOOL(ast->frozen_string_literal));
- if (ast->coverage_enabled >= 0) rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), RBOOL(ast->coverage_enabled));
- return opt;
-}
-
-static void
-rb_iseq_make_compile_option(rb_compile_option_t *option, VALUE opt)
-{
- Check_Type(opt, T_HASH);
- set_compile_option_from_hash(option, opt);
+#define SET_COMPILE_OPTION(o, a, mem) \
+ ((a)->mem < 0 ? 0 : ((o)->mem = (a)->mem > 0))
+ SET_COMPILE_OPTION(option, ast, frozen_string_literal);
+ SET_COMPILE_OPTION(option, ast, coverage_enabled);
+#undef SET_COMPILE_OPTION
+ return option;
}
static void
@@ -919,8 +914,7 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
if (!option) option = &COMPILE_OPTION_DEFAULT;
if (ast) {
new_opt = *option;
- rb_iseq_make_compile_option(&new_opt, make_compile_option_from_ast(ast));
- option = &new_opt;
+ option = set_compile_option_from_ast(&new_opt, ast);
}
VALUE script_lines = Qnil;