summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/string.c b/string.c
index 3a0089669c..d834754743 100644
--- a/string.c
+++ b/string.c
@@ -17,6 +17,7 @@
#include "probes.h"
#include "gc.h"
#include <assert.h>
+#include "id.h"
#define BEG(no) (regs->beg[(no)])
#define END(no) (regs->end[(no)])
@@ -1227,8 +1228,6 @@ str_shared_replace(VALUE str, VALUE str2)
}
}
-static ID id_to_s;
-
VALUE
rb_obj_as_string(VALUE obj)
{
@@ -1237,7 +1236,7 @@ rb_obj_as_string(VALUE obj)
if (RB_TYPE_P(obj, T_STRING)) {
return obj;
}
- str = rb_funcall(obj, id_to_s, 0);
+ str = rb_funcall(obj, idTo_s, 0);
if (!RB_TYPE_P(str, T_STRING))
return rb_any_to_s(obj);
OBJ_INFECT(str, obj);
@@ -2761,7 +2760,7 @@ rb_str_equal(VALUE str1, VALUE str2)
{
if (str1 == str2) return Qtrue;
if (!RB_TYPE_P(str2, T_STRING)) {
- if (!rb_respond_to(str2, rb_intern("to_str"))) {
+ if (!rb_respond_to(str2, idTo_str)) {
return Qfalse;
}
return rb_equal(str2, str1);
@@ -2816,7 +2815,7 @@ rb_str_cmp_m(VALUE str1, VALUE str2)
int result;
if (!RB_TYPE_P(str2, T_STRING)) {
- VALUE tmp = rb_check_funcall(str2, rb_intern("to_str"), 0, 0);
+ VALUE tmp = rb_check_funcall(str2, idTo_str, 0, 0);
if (RB_TYPE_P(tmp, T_STRING)) {
result = rb_str_cmp(str1, tmp);
}
@@ -3219,7 +3218,7 @@ rb_str_match(VALUE x, VALUE y)
generic:
default:
- return rb_funcall(y, rb_intern("=~"), 1, x);
+ return rb_funcall(y, idEqTilde, 1, x);
}
}
@@ -3699,7 +3698,7 @@ str_upto_each(VALUE beg, VALUE end, int excl, int (*each)(VALUE, VALUE), VALUE a
}
}
else {
- ID op = excl ? '<' : rb_intern("<=");
+ ID op = excl ? '<' : idLE;
VALUE args[2], fmt = rb_obj_freeze(rb_usascii_str_new_cstr("%.*d"));
args[0] = INT2FIX(width);
@@ -8044,7 +8043,7 @@ rb_str_sum(int argc, VALUE *argv, VALUE str)
sum = rb_funcall(sum, '+', 1, LONG2FIX(sum0));
}
- mod = rb_funcall(INT2FIX(1), rb_intern("<<"), 1, INT2FIX(bits));
+ mod = rb_funcall(INT2FIX(1), idLTLT, 1, INT2FIX(bits));
mod = rb_funcall(mod, '-', 1, INT2FIX(1));
sum = rb_funcall(sum, '&', 1, mod);
}
@@ -9368,8 +9367,6 @@ Init_String(void)
rb_define_method(rb_cString, "valid_encoding?", rb_str_valid_encoding_p, 0);
rb_define_method(rb_cString, "ascii_only?", rb_str_is_ascii_only_p, 0);
- id_to_s = rb_intern("to_s");
-
rb_fs = Qnil;
rb_define_variable("$;", &rb_fs);
rb_define_variable("$-F", &rb_fs);