From a4302524d06c2b63617285286dcf41b5a45baf75 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Wed, 19 Aug 2020 10:36:53 +0900 Subject: Avoid using `mrb_check_intern_str()`. We call `mrb_intern_str()` later anyway, so there's no need to avoid defining a new symbol here. --- mrbgems/mruby-struct/src/struct.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'mrbgems/mruby-struct/src') diff --git a/mrbgems/mruby-struct/src/struct.c b/mrbgems/mruby-struct/src/struct.c index 423cf99a5..1189381cb 100644 --- a/mrbgems/mruby-struct/src/struct.c +++ b/mrbgems/mruby-struct/src/struct.c @@ -428,12 +428,8 @@ mrb_struct_aref(mrb_state *mrb, mrb_value s) mrb_value idx = mrb_get_arg1(mrb); if (mrb_string_p(idx)) { - mrb_value sym = mrb_check_intern_str(mrb, idx); - - if (mrb_nil_p(sym)) { - mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%v' in struct", idx); - } - idx = sym; + mrb_sym sym = mrb_intern_str(mrb, idx); + idx = mrb_symbol_value(sym); } if (mrb_symbol_p(idx)) { return struct_aref_sym(mrb, s, mrb_symbol(idx)); @@ -495,12 +491,8 @@ mrb_struct_aset(mrb_state *mrb, mrb_value s) mrb_get_args(mrb, "oo", &idx, &val); if (mrb_string_p(idx)) { - mrb_value sym = mrb_check_intern_str(mrb, idx); - - if (mrb_nil_p(sym)) { - mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%v' in struct", idx); - } - idx = sym; + mrb_sym sym = mrb_intern_str(mrb, idx); + idx = mrb_symbol_value(sym); } if (mrb_symbol_p(idx)) { return mrb_struct_aset_sym(mrb, s, mrb_symbol(idx), val); -- cgit v1.2.3