diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-12-20 17:46:57 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-12-20 17:46:57 +0900 |
| commit | 8a5f18a1d8bb50b58e513a150ce0c8f131f672a9 (patch) | |
| tree | ab92361ba85338dc307b84707c15c7c703f92fec | |
| parent | a42b676ae928249d6a6f6a3a370d84b29bb2a613 (diff) | |
| download | mruby-8a5f18a1d8bb50b58e513a150ce0c8f131f672a9.tar.gz mruby-8a5f18a1d8bb50b58e513a150ce0c8f131f672a9.zip | |
codegen.c: generate `OP_SETIDX`; close #5608
Note that the current implantation only calls `[]=` method. No
performance improvement. Just 2 bytes less byte code per assignment.
| -rw-r--r-- | mrbgems/mruby-compiler/core/codegen.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index 751d0d19a..16ae95e2e 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -1750,13 +1750,16 @@ gen_call(codegen_scope *s, node *tree, mrb_sym name, int sp, int val, int safe) else if (!noop && sym == MRB_OPSYM_2(s->mrb, eq) && n == 1) { genop_1(s, OP_EQ, cursp()); } + else if (!noop && sym == MRB_OPSYM_2(s->mrb, aset) && n == 2) { + genop_1(s, OP_SETIDX, cursp()); + } else if (!noop && n == 0 && gen_uniop(s, sym, cursp())) { /* constant folding succeeded */ } else if (!noop && n == 1 && gen_binop(s, sym, cursp())) { /* constant folding succeeded */ } - else if (noself ){ + else if (noself){ genop_3(s, blk ? OP_SSENDB : OP_SSEND, cursp(), new_sym(s, sym), n|(nk<<4)); } else { |
