summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKOBAYASHI Shuji <[email protected]>2019-02-11 21:09:40 +0900
committerKOBAYASHI Shuji <[email protected]>2019-02-11 21:09:40 +0900
commitc6e2d91536acfb05803323c42eccef1811e7bf23 (patch)
tree8957a9ba481a4b15f8a8d25be73a4b76541a69fd
parent55e58d85122bc65b3ab9428ea79d863ab0f8170e (diff)
downloadmruby-c6e2d91536acfb05803323c42eccef1811e7bf23.tar.gz
mruby-c6e2d91536acfb05803323c42eccef1811e7bf23.zip
Small refactoring in `codegen.c`
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 48bf06461..bfc08cd94 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -2357,13 +2357,9 @@ codegen(codegen_scope *s, node *tree, int val)
case NODE_BACK_REF:
if (val) {
- char buf[3];
- int sym;
+ char buf[] = {'$', nchar(tree)};
+ int sym = new_sym(s, mrb_intern(s->mrb, buf, sizeof(buf)));
- buf[0] = '$';
- buf[1] = nchar(tree);
- buf[2] = 0;
- sym = new_sym(s, mrb_intern_cstr(s->mrb, buf));
genop_2(s, OP_GETGV, cursp(), sym);
push();
}