summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYukihiro Matsumoto <[email protected]>2012-08-08 00:25:35 +0900
committerYukihiro Matsumoto <[email protected]>2012-08-08 00:25:35 +0900
commit8af5a999bfcaecbc9c1ff791d03f5904b1e5172f (patch)
tree0848b9ce90996a2dce3cf1103da6b002b49023e8
parentf0462b4122edd6a6fb42d07f469813a05f0620d8 (diff)
downloadmruby-8af5a999bfcaecbc9c1ff791d03f5904b1e5172f.tar.gz
mruby-8af5a999bfcaecbc9c1ff791d03f5904b1e5172f.zip
store :initialize in mrb structure
-rw-r--r--include/mruby.h1
-rw-r--r--src/class.c6
-rw-r--r--src/symbol.c1
3 files changed, 5 insertions, 3 deletions
diff --git a/include/mruby.h b/include/mruby.h
index 451b4eb8b..dbd6b2650 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -238,6 +238,7 @@ typedef struct mrb_state {
struct mrb_irep **irep;
size_t irep_len, irep_capa;
+ mrb_sym init_sym;
struct RClass *object_class;
struct RClass *class_class;
struct RClass *module_class;
diff --git a/src/class.c b/src/class.c
index 7802c34bd..ae4d45ff1 100644
--- a/src/class.c
+++ b/src/class.c
@@ -921,7 +921,7 @@ mrb_funcall(mrb_state *mrb, mrb_value self, const char *name, int argc, ...)
void
mrb_obj_call_init(mrb_state *mrb, mrb_value obj, int argc, mrb_value *argv)
{
- mrb_funcall_argv(mrb, obj, mrb_intern(mrb, "initialize"), argc, argv);
+ mrb_funcall_argv(mrb, obj, mrb->init_sym, argc, argv);
}
/*
@@ -960,7 +960,7 @@ mrb_class_new_instance_m(mrb_state *mrb, mrb_value klass)
c = (struct RClass*)mrb_obj_alloc(mrb, k->tt, k);
c->super = k;
obj = mrb_obj_value(c);
- mrb_funcall_with_block(mrb, obj, mrb_intern(mrb, "initialize"), argc, argv, blk);
+ mrb_funcall_with_block(mrb, obj, mrb->init_sym, argc, argv, blk);
return obj;
}
@@ -979,7 +979,7 @@ mrb_instance_new(mrb_state *mrb, mrb_value cv)
o = (struct RObject*)mrb_obj_alloc(mrb, ttype, c);
obj = mrb_obj_value(o);
mrb_get_args(mrb, "*&", &argv, &argc, &blk);
- mrb_funcall_with_block(mrb, obj, mrb_intern(mrb, "initialize"), argc, argv, blk);
+ mrb_funcall_with_block(mrb, obj, mrb->init_sym, argc, argv, blk);
return obj;
}
diff --git a/src/symbol.c b/src/symbol.c
index b81296929..fdb0aa861 100644
--- a/src/symbol.c
+++ b/src/symbol.c
@@ -404,4 +404,5 @@ mrb_init_symbol(mrb_state *mrb)
mrb_define_method(mrb, sym, "to_sym", sym_to_sym, ARGS_NONE()); /* 15.2.11.3.4 */
mrb_define_method(mrb, sym, "inspect", sym_inspect, ARGS_NONE()); /* 15.2.11.3.5(x) */
mrb_define_method(mrb, sym, "<=>", sym_cmp, ARGS_REQ(1));
+ mrb->init_sym = mrb_intern(mrb, "initialize");
}