summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-22 13:09:37 (GMT)
committerkazu <kazu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-22 13:09:37 (GMT)
commitb8cc476ce9a3e931fb474ee83e8ae147bcd9c86e (patch)
tree7e4873181f0b7e90bb83cdd79d0753f092b134eb
parent4f03a239dcd6704e4ae7a7029dc6b31d579e9f7c (diff)
use predefined IDs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--complex.c7
-rw-r--r--dir.c3
-rw-r--r--io.c2
-rw-r--r--proc.c2
-rw-r--r--rational.c6
-rw-r--r--variable.c2
-rw-r--r--vm_eval.c4
7 files changed, 14 insertions, 12 deletions
diff --git a/complex.c b/complex.c
index cee9770..9b54d6b 100644
--- a/complex.c
+++ b/complex.c
@@ -12,6 +12,7 @@
#endif
#include <math.h>
#include "internal.h"
+#include "id.h"
#define NDEBUG
#include "ruby_assert.h"
@@ -33,10 +34,12 @@ static VALUE nucomp_arg(VALUE self);
static ID id_abs, id_arg,
id_denominator, id_expt, id_fdiv,
id_negate, id_numerator, id_quo,
- id_real_p, id_to_f, id_to_i, id_to_r,
+ id_real_p, id_to_f,
id_i_real, id_i_imag,
id_finite_p, id_infinite_p, id_rationalize,
id_PI;
+#define id_to_i idTo_i
+#define id_to_r idTo_r
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
@@ -2204,8 +2207,6 @@ Init_Complex(void)
id_quo = rb_intern("quo");
id_real_p = rb_intern("real?");
id_to_f = rb_intern("to_f");
- id_to_i = rb_intern("to_i");
- id_to_r = rb_intern("to_r");
id_i_real = rb_intern("@real");
id_i_imag = rb_intern("@image"); /* @image, not @imag */
id_finite_p = rb_intern("finite?");
diff --git a/dir.c b/dir.c
index ab2902c..26cc122 100644
--- a/dir.c
+++ b/dir.c
@@ -14,6 +14,7 @@
#include "ruby/encoding.h"
#include "ruby/thread.h"
#include "internal.h"
+#include "id.h"
#include "encindex.h"
#include <sys/types.h>
@@ -662,7 +663,7 @@ dir_inspect(VALUE dir)
rb_str_cat2(str, ">");
return str;
}
- return rb_funcallv(dir, rb_intern("to_s"), 0, 0);
+ return rb_funcallv(dir, idTo_s, 0, 0);
}
/* Workaround for Solaris 10 that does not have dirfd.
diff --git a/io.c b/io.c
index fd4892f..501d14e 100644
--- a/io.c
+++ b/io.c
@@ -4742,7 +4742,7 @@ static VALUE
ignore_closed_stream(VALUE io, VALUE exc)
{
enum {mesg_len = sizeof(closed_stream)-1};
- VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
+ VALUE mesg = rb_attr_get(exc, idMesg);
if (!RB_TYPE_P(mesg, T_STRING) ||
RSTRING_LEN(mesg) != mesg_len ||
memcmp(RSTRING_PTR(mesg), closed_stream, mesg_len)) {
diff --git a/proc.c b/proc.c
index 3fbe099..4f909da 100644
--- a/proc.c
+++ b/proc.c
@@ -3082,7 +3082,7 @@ Init_Proc(void)
rb_undef_alloc_func(rb_cProc);
rb_define_singleton_method(rb_cProc, "new", rb_proc_s_new, -1);
- rb_add_method(rb_cProc, rb_intern("call"), VM_METHOD_TYPE_OPTIMIZED,
+ rb_add_method(rb_cProc, idCall, VM_METHOD_TYPE_OPTIMIZED,
(void *)OPTIMIZED_METHOD_TYPE_CALL, METHOD_VISI_PUBLIC);
rb_add_method(rb_cProc, rb_intern("[]"), VM_METHOD_TYPE_OPTIMIZED,
(void *)OPTIMIZED_METHOD_TYPE_CALL, METHOD_VISI_PUBLIC);
diff --git a/rational.c b/rational.c
index d82d487..7491b81 100644
--- a/rational.c
+++ b/rational.c
@@ -33,8 +33,9 @@
VALUE rb_cRational;
-static ID id_abs, id_idiv, id_integer_p, id_to_i,
+static ID id_abs, id_idiv, id_integer_p,
id_i_num, id_i_den;
+#define id_to_i idTo_i
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
#define f_inspect rb_inspect
@@ -2003,7 +2004,7 @@ rb_rational_den(VALUE rat)
#define id_denominator rb_intern("denominator")
#define f_denominator(x) rb_funcall((x), id_denominator, 0)
-#define id_to_r rb_intern("to_r")
+#define id_to_r idTo_r
#define f_to_r(x) rb_funcall((x), id_to_r, 0)
/*
@@ -2684,7 +2685,6 @@ Init_Rational(void)
id_abs = rb_intern("abs");
id_idiv = rb_intern("div");
id_integer_p = rb_intern("integer?");
- id_to_i = rb_intern("to_i");
id_i_num = rb_intern("@numerator");
id_i_den = rb_intern("@denominator");
diff --git a/variable.c b/variable.c
index 3e37bc2..3f9725a 100644
--- a/variable.c
+++ b/variable.c
@@ -1748,7 +1748,7 @@ uninitialized_constant(VALUE klass, VALUE name)
VALUE
rb_const_missing(VALUE klass, VALUE name)
{
- VALUE value = rb_funcallv(klass, rb_intern("const_missing"), 1, &name);
+ VALUE value = rb_funcallv(klass, idConst_missing, 1, &name);
rb_vm_inc_const_missing_count();
return value;
}
diff --git a/vm_eval.c b/vm_eval.c
index fea06a7..3a82a08 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -2150,9 +2150,9 @@ Init_vm_eval(void)
rb_define_private_method(rb_cBasicObject, "method_missing", rb_method_missing, -1);
#if 1
- rb_add_method(rb_cBasicObject, rb_intern("__send__"),
+ rb_add_method(rb_cBasicObject, id__send__,
VM_METHOD_TYPE_OPTIMIZED, (void *)OPTIMIZED_METHOD_TYPE_SEND, METHOD_VISI_PUBLIC);
- rb_add_method(rb_mKernel, rb_intern("send"),
+ rb_add_method(rb_mKernel, idSend,
VM_METHOD_TYPE_OPTIMIZED, (void *)OPTIMIZED_METHOD_TYPE_SEND, METHOD_VISI_PUBLIC);
#else
rb_define_method(rb_cBasicObject, "__send__", rb_f_send, -1);