diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-08-19 10:36:53 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-12 16:21:49 +0900 |
| commit | a4302524d06c2b63617285286dcf41b5a45baf75 (patch) | |
| tree | 3c96300f69d6ae51dda305c9c9b5daa70542b7cd /mrbgems/mruby-struct/src/struct.c | |
| parent | 12d31c33afaa9b4e87f364b3622808061b7a4218 (diff) | |
| download | mruby-a4302524d06c2b63617285286dcf41b5a45baf75.tar.gz mruby-a4302524d06c2b63617285286dcf41b5a45baf75.zip | |
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.
Diffstat (limited to 'mrbgems/mruby-struct/src/struct.c')
| -rw-r--r-- | mrbgems/mruby-struct/src/struct.c | 16 |
1 files changed, 4 insertions, 12 deletions
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); |
