summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-math
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-06-01 10:36:28 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:20:59 +0900
commit2a366ffba8397c6f848d659dce76e03e1bf05d17 (patch)
treeab3d1e81ebf3659e3f5776729c8ebe1b7cbbee86 /mrbgems/mruby-math
parent8864c30d161e627438b86a986c19c048eb31bcb4 (diff)
downloadmruby-2a366ffba8397c6f848d659dce76e03e1bf05d17.tar.gz
mruby-2a366ffba8397c6f848d659dce76e03e1bf05d17.zip
Use functions that take symbols to reduce string litrals in C.
Diffstat (limited to 'mrbgems/mruby-math')
-rw-r--r--mrbgems/mruby-math/src/math.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/mrbgems/mruby-math/src/math.c b/mrbgems/mruby-math/src/math.c
index 88b33771b..ff1e84684 100644
--- a/mrbgems/mruby-math/src/math.c
+++ b/mrbgems/mruby-math/src/math.c
@@ -16,8 +16,8 @@
static void
domain_error(mrb_state *mrb, const char *func)
{
- struct RClass *math = mrb_module_get(mrb, "Math");
- struct RClass *domainerror = mrb_class_get_under(mrb, math, "DomainError");
+ struct RClass *math = mrb_module_get_id(mrb, MRB_SYM(Math));
+ struct RClass *domainerror = mrb_class_get_under_id(mrb, math, MRB_SYM(DomainError));
mrb_raisef(mrb, domainerror, "Numerical argument is out of domain - %s", func);
}
@@ -730,18 +730,18 @@ mrb_mruby_math_gem_init(mrb_state* mrb)
struct RClass *mrb_math;
mrb_math = mrb_define_module(mrb, "Math");
- mrb_define_class_under(mrb, mrb_math, "DomainError", mrb->eStandardError_class);
+ mrb_define_class_under_id(mrb, mrb_math, MRB_SYM(DomainError), mrb->eStandardError_class);
#ifdef M_PI
- mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(mrb, M_PI));
+ mrb_define_const_id(mrb, mrb_math, MRB_SYM(PI), mrb_float_value(mrb, M_PI));
#else
- mrb_define_const(mrb, mrb_math, "PI", mrb_float_value(mrb, atan(1.0)*4.0));
+ mrb_define_const_id(mrb, mrb_math, MRB_SYM(PI), mrb_float_value(mrb, atan(1.0)*4.0));
#endif
#ifdef M_E
- mrb_define_const(mrb, mrb_math, "E", mrb_float_value(mrb, M_E));
+ mrb_define_const_id(mrb, mrb_math, MRB_SYM(E), mrb_float_value(mrb, M_E));
#else
- mrb_define_const(mrb, mrb_math, "E", mrb_float_value(mrb, exp(1.0)));
+ mrb_define_const_id(mrb, mrb_math, MRB_SYM(E), mrb_float_value(mrb, exp(1.0)));
#endif
mrb_define_module_function(mrb, mrb_math, "sin", math_sin, MRB_ARGS_REQ(1));