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.
parent 12d31c33
...@@ -428,12 +428,8 @@ mrb_struct_aref(mrb_state *mrb, mrb_value s) ...@@ -428,12 +428,8 @@ mrb_struct_aref(mrb_state *mrb, mrb_value s)
mrb_value idx = mrb_get_arg1(mrb); mrb_value idx = mrb_get_arg1(mrb);
if (mrb_string_p(idx)) { if (mrb_string_p(idx)) {
mrb_value sym = mrb_check_intern_str(mrb, idx); mrb_sym sym = mrb_intern_str(mrb, idx);
idx = mrb_symbol_value(sym);
if (mrb_nil_p(sym)) {
mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%v' in struct", idx);
}
idx = sym;
} }
if (mrb_symbol_p(idx)) { if (mrb_symbol_p(idx)) {
return struct_aref_sym(mrb, s, mrb_symbol(idx)); return struct_aref_sym(mrb, s, mrb_symbol(idx));
...@@ -495,12 +491,8 @@ mrb_struct_aset(mrb_state *mrb, mrb_value s) ...@@ -495,12 +491,8 @@ mrb_struct_aset(mrb_state *mrb, mrb_value s)
mrb_get_args(mrb, "oo", &idx, &val); mrb_get_args(mrb, "oo", &idx, &val);
if (mrb_string_p(idx)) { if (mrb_string_p(idx)) {
mrb_value sym = mrb_check_intern_str(mrb, idx); mrb_sym sym = mrb_intern_str(mrb, idx);
idx = mrb_symbol_value(sym);
if (mrb_nil_p(sym)) {
mrb_name_error(mrb, mrb_intern_str(mrb, idx), "no member '%v' in struct", idx);
}
idx = sym;
} }
if (mrb_symbol_p(idx)) { if (mrb_symbol_p(idx)) {
return mrb_struct_aset_sym(mrb, s, mrb_symbol(idx), val); return mrb_struct_aset_sym(mrb, s, mrb_symbol(idx), val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment