Project

General

Profile

Feature #7508 ยป clean_up_rb_interns.patch

Anonymous, 12/04/2012 06:54 PM

View differences:

array.c
VALUE rb_cArray;
static ID id_cmp, id_div, id_power;
static ID id_cmp, id_div, id_power, id_sort_by, id_to_ary;
#define ARY_DEFAULT_SIZE 16
#define ARY_MAX_SIZE (LONG_MAX / (int)sizeof(VALUE))
......
RETURN_SIZED_ENUMERATOR(ary, 0, 0, rb_ary_length);
rb_ary_modify(ary);
sorted = rb_block_call(ary, rb_intern("sort_by"), 0, 0, sort_by_i, 0);
sorted = rb_block_call(ary, id_sort_by, 0, 0, sort_by_i, 0);
rb_ary_replace(ary, sorted);
return ary;
}
......
{
if (ary1 == ary2) return Qtrue;
if (!RB_TYPE_P(ary2, T_ARRAY)) {
if (!rb_respond_to(ary2, rb_intern("to_ary"))) {
if (!rb_respond_to(ary2, id_to_ary)) {
return Qfalse;
}
return rb_equal(ary2, ary1);
......
rb_define_method(rb_cArray, "drop_while", rb_ary_drop_while, 0);
rb_define_method(rb_cArray, "bsearch", rb_ary_bsearch, 0);
id_cmp = rb_intern("<=>");
sym_random = ID2SYM(rb_intern("random"));
id_div = rb_intern("div");
id_power = rb_intern("**");
id_cmp = rb_intern("<=>");
sym_random = ID2SYM(rb_intern("random"));
id_div = rb_intern("div");
id_power = rb_intern("**");
id_sort_by = rb_intern("sort_by");
id_to_ary = rb_intern("to_ary");
}
bignum.c
#include "ruby/thread.h"
#include "ruby/util.h"
#include "internal.h"
#include "id.h"
#ifdef HAVE_STRINGS_H
#include <strings.h>
......
return rb_integer_float_cmp(x, y);
default:
return rb_num_coerce_cmp(x, y, rb_intern("<=>"));
return rb_num_coerce_cmp(x, y, idCmp);
}
if (RBIGNUM_SIGN(x) > RBIGNUM_SIGN(y)) return INT2FIX(1);
......
{
ID id = 0;
switch (op) {
case big_op_gt: id = '>'; break;
case big_op_ge: id = rb_intern(">="); break;
case big_op_lt: id = '<'; break;
case big_op_le: id = rb_intern("<="); break;
case big_op_gt: id = idGT; break;
case big_op_ge: id = idGE; break;
case big_op_lt: id = idLT; break;
case big_op_le: id = idLE; break;
}
return rb_num_coerce_relop(x, y, id);
}
......
VALUE
rb_big_div(VALUE x, VALUE y)
{
return rb_big_divide(x, y, '/');
return rb_big_divide(x, y, idDIV);
}
/*
......
case T_FLOAT:
d = RFLOAT_VALUE(y);
if ((!RBIGNUM_SIGN(x) && !BIGZEROP(x)) && d != round(d))
return rb_funcall(rb_complex_raw1(x), rb_intern("**"), 1, y);
return rb_funcall(rb_complex_raw1(x), idPow, 1, y);
break;
case T_BIGNUM:
......
yy = FIX2LONG(y);
if (yy < 0)
return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
return rb_funcall(rb_rational_raw1(x), idPow, 1, y);
else {
VALUE z = 0;
SIGNED_VALUE mask;
......
break;
default:
return rb_num_coerce_bin(x, y, rb_intern("**"));
return rb_num_coerce_bin(x, y, idPow);
}
return DBL2NUM(pow(rb_big2dbl(x), d));
}
complex.c
id_denominator, id_divmod, id_eqeq_p, id_expt, id_fdiv, id_floor,
id_idiv, id_imag, id_inspect, id_negate, id_numerator, id_quo,
id_real, id_real_p, id_to_f, id_to_i, id_to_r, id_to_s,
id_i_real, id_i_imag;
id_i_real, id_i_imag, id_PI;
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
......
return f_mul(self, self);
}
#define id_PI rb_intern("PI")
/*
* call-seq:
* num.arg -> 0 or float
......
id_to_s = rb_intern("to_s");
id_i_real = rb_intern("@real");
id_i_imag = rb_intern("@image"); /* @image, not @imag */
id_PI = rb_intern("PI");
rb_cComplex = rb_define_class("Complex", rb_cNumeric);
numeric.c
double dx = RFLOAT_VALUE(x);
double dy = RFLOAT_VALUE(y);
if (dx < 0 && dy != round(dy))
return rb_funcall(rb_complex_raw1(x), rb_intern("**"), 1, y);
return rb_funcall(rb_complex_raw1(x), idPow, 1, y);
return DBL2NUM(pow(dx, dy));
}
default:
return rb_num_coerce_bin(x, y, rb_intern("**"));
return rb_num_coerce_bin(x, y, idPow);
}
}
......
if (a > 0.0) return INT2FIX(1);
return INT2FIX(-1);
}
return rb_num_coerce_cmp(x, y, rb_intern("<=>"));
return rb_num_coerce_cmp(x, y, idCmp);
}
return rb_dbl_cmp(a, b);
}
......
break;
default:
return rb_num_coerce_relop(x, y, rb_intern(">="));
return rb_num_coerce_relop(x, y, idGE);
}
#if defined(_MSC_VER) && _MSC_VER < 1300
if (isnan(a)) return Qfalse;
......
break;
default:
return rb_num_coerce_relop(x, y, rb_intern("<="));
return rb_num_coerce_relop(x, y, idLE);
}
#if defined(_MSC_VER) && _MSC_VER < 1300
if (isnan(a)) return Qfalse;
......
h = rb_funcall(f, '/', 1, INT2FIX(2));
r = rb_funcall(num, '%', 1, f);
n = rb_funcall(num, '-', 1, r);
op = negative_int_p(num) ? rb_intern("<=") : '<';
op = negative_int_p(num) ? idLE : '<';
if (!RTEST(rb_funcall(r, op, 1, h))) {
n = rb_funcall(n, '+', 1, f);
}
......
long b = FIX2LONG(y);
if (b < 0)
return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
return rb_funcall(rb_rational_raw1(x), idPow, 1, y);
if (b == 0) return INT2FIX(1);
if (b == 1) return x;
......
case T_BIGNUM:
if (negative_int_p(y))
return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
return rb_funcall(rb_rational_raw1(x), idPow, 1, y);
if (a == 0) return INT2FIX(0);
if (a == 1) return INT2FIX(1);
......
{
double dy = RFLOAT_VALUE(y);
if (a < 0 && dy != round(dy))
return rb_funcall(rb_complex_raw1(x), rb_intern("**"), 1, y);
return rb_funcall(rb_complex_raw1(x), idPow, 1, y);
return DBL2NUM(pow((double)a, dy));
}
default:
return rb_num_coerce_bin(x, y, rb_intern("**"));
return rb_num_coerce_bin(x, y, idPow);
}
}
......
case T_FLOAT:
return rb_integer_float_cmp(x, y);
default:
return rb_num_coerce_cmp(x, y, rb_intern("<=>"));
return rb_num_coerce_cmp(x, y, idCmp);
}
}
......
return rel == INT2FIX(1) || rel == INT2FIX(0) ? Qtrue : Qfalse;
}
default:
return rb_num_coerce_relop(x, y, rb_intern(">="));
return rb_num_coerce_relop(x, y, idGE);
}
}
......
return rel == INT2FIX(-1) || rel == INT2FIX(0) ? Qtrue : Qfalse;
}
default:
return rb_num_coerce_relop(x, y, rb_intern("<="));
return rb_num_coerce_relop(x, y, idLE);
}
}
random.c
*/
#include "ruby/ruby.h"
#include "id.h"
#include <limits.h>
#ifdef HAVE_UNISTD_H
......
if (rb_obj_class(self) != rb_obj_class(other)) return Qfalse;
r1 = get_rnd(self);
r2 = get_rnd(other);
if (!RTEST(rb_funcall2(r1->seed, rb_intern("=="), 1, &r2->seed))) return Qfalse;
if (!RTEST(rb_funcall2(r1->seed, idEq, 1, &r2->seed))) return Qfalse;
if (memcmp(r1->mt.state, r2->mt.state, sizeof(r1->mt.state))) return Qfalse;
if ((r1->mt.next - r1->mt.state) != (r2->mt.next - r2->mt.state)) return Qfalse;
if (r1->mt.left != r2->mt.left) return Qfalse;
string.c
ENC_CODERANGE_SET(str, cr);
}
static ID id_to_s;
static ID id_to_s, id_to_str;
VALUE
rb_obj_as_string(VALUE obj)
......
{
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, id_to_str)) {
return Qfalse;
}
return rb_equal(str2, str1);
......
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, id_to_str, 0, 0);
if (RB_TYPE_P(tmp, T_STRING)) {
result = rb_str_cmp(str1, tmp);
}
else if ((tmp = rb_check_funcall(str2, rb_intern("<=>"), 1, &str1)) ==
else if ((tmp = rb_check_funcall(str2, idCmp, 1, &str1)) ==
Qundef) {
return Qnil;
}
......
generic:
default:
return rb_funcall(y, rb_intern("=~"), 1, x);
return rb_funcall(y, idEqTilde, 1, x);
}
}
......
}
}
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);
......
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);
}
......
rb_define_method(rb_cString, "ascii_only?", rb_str_is_ascii_only_p, 0);
id_to_s = rb_intern("to_s");
id_to_str = rb_intern("to_str");
rb_fs = Qnil;
rb_define_variable("$;", &rb_fs);
thread.c
VALUE rb_cMutex;
VALUE rb_cThreadShield;
static ID id_immediate, id_on_blocking, id_defer;
static void sleep_timeval(rb_thread_t *th, struct timeval time, int spurious_check);
static void sleep_wait_for_interrupt(rb_thread_t *th, double sleepsec, int spurious_check);
static void sleep_forever(rb_thread_t *th, int nodeadlock, int spurious_check);
......
VALUE klass = ancestors_ptr[j];
VALUE sym;
/* TODO: remove rb_intern() */
if ((sym = rb_hash_aref(mask, klass)) != Qnil) {
if (sym == ID2SYM(rb_intern("immediate"))) {
if (sym == ID2SYM(id_immediate)) {
return INTERRUPT_IMMEDIATE;
}
else if (sym == ID2SYM(rb_intern("on_blocking"))) {
else if (sym == ID2SYM(id_on_blocking)) {
return INTERRUPT_ON_BLOCKING;
}
else if (sym == ID2SYM(rb_intern("defer"))) {
else if (sym == ID2SYM(id_defer)) {
return INTERRUPT_DEFER;
}
else {
......
static int
async_interrupt_timing_arg_check_i(VALUE key, VALUE val)
{
VALUE immediate = ID2SYM(rb_intern("immediate"));
VALUE on_blocking = ID2SYM(rb_intern("on_blocking"));
VALUE defer = ID2SYM(rb_intern("defer"));
VALUE immediate = ID2SYM(id_immediate);
VALUE on_blocking = ID2SYM(id_on_blocking);
VALUE defer = ID2SYM(id_defer);
if (val != immediate && val != on_blocking && val != defer) {
rb_raise(rb_eArgError, "unknown mask signature");
......
rb_define_method(rb_cMutex, "synchronize", rb_mutex_synchronize_m, 0);
recursive_key = rb_intern("__recursive_key__");
id_immediate = rb_intern("immediate");
id_on_blocking = rb_intern("on_blocking");
id_defer = rb_intern("defer");
rb_eThreadError = rb_define_class("ThreadError", rb_eStandardError);
/* init thread core */
time.c
#include "timev.h"
static ID id_divmod, id_mul, id_submicro, id_nano_num, id_nano_den, id_offset;
static ID id_eq, id_ne, id_quo, id_div, id_cmp, id_lshift;
static ID id_divmod, id_mul, id_submicro, id_nano_num, id_nano_den, id_offset,
id_eq, id_ne, id_quo, id_div, id_cmp, id_lshift, id_to_r, id_to_str,
id_dst, id_std;
#define NDIV(x,y) (-(-((x)+1)/(y))-1)
#define NMOD(x,y) ((y)-(-((x)+1)%(y))-1)
......
goto typeerror;
default:
if ((tmp = rb_check_funcall(v, rb_intern("to_r"), 0, NULL)) != Qundef) {
if (rb_respond_to(v, rb_intern("to_str"))) goto typeerror;
if ((tmp = rb_check_funcall(v, id_to_r, 0, NULL)) != Qundef) {
if (rb_respond_to(v, id_to_str)) goto typeerror;
v = tmp;
break;
}
......
vtm.utc_offset = Qnil;
if (!NIL_P(v[6])) {
VALUE arg = v[6];
if (arg == ID2SYM(rb_intern("dst")))
if (arg == ID2SYM(id_dst))
vtm.isdst = 1;
else if (arg == ID2SYM(rb_intern("std")))
else if (arg == ID2SYM(id_std))
vtm.isdst = 0;
else
vtm.utc_offset = utc_offset_arg(arg);
......
else {
VALUE tmp;
tmp = rb_funcall(time2, rb_intern("<=>"), 1, time1);
tmp = rb_funcall(time2, id_cmp, 1, time1);
if (NIL_P(tmp)) return Qnil;
n = -rb_cmpint(tmp, time1, time2);
......
id_nano_num = rb_intern("nano_num");
id_nano_den = rb_intern("nano_den");
id_offset = rb_intern("offset");
id_to_r = rb_intern("to_r");
id_to_str = rb_intern("to_str");
id_dst = rb_intern("dst");
id_std = rb_intern("std");
rb_cTime = rb_define_class("Time", rb_cObject);
rb_include_module(rb_cTime, rb_mComparable);
vm_eval.c
static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref, rb_block_t *base_block);
static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary);
static ID id_message, id_call;
/* vm_backtrace.c */
VALUE vm_backtrace_str_ary(rb_thread_t *th, int lev, int n);
......
if (!format) {
format = "undefined method `%s' for %s";
}
mesg = rb_const_get(exc, rb_intern("message"));
mesg = rb_const_get(exc, id_message);
if (rb_method_basic_definition_p(CLASS_OF(mesg), '!')) {
args[n++] = rb_name_err_mesg_new(mesg, rb_str_new2(format), obj, argv[0]);
}
......
PUSH_TAG();
rb_set_safe_level_force(level);
if ((state = EXEC_TAG()) == 0) {
val = rb_funcall2(cmd, rb_intern("call"), RARRAY_LENINT(arg),
val = rb_funcall2(cmd, id_call, RARRAY_LENINT(arg),
RARRAY_PTR(arg));
}
POP_TAG();
......
rb_define_method(rb_cBasicObject, "instance_exec", rb_obj_instance_exec, -1);
rb_define_private_method(rb_cBasicObject, "method_missing", rb_method_missing, -1);
id_message = rb_intern("message");
id_call = rb_intern("call");
#if 1
rb_add_method(rb_cBasicObject, rb_intern("__send__"),
VM_METHOD_TYPE_OPTIMIZED, (void *)OPTIMIZED_METHOD_TYPE_SEND, 0);
    (1-1/1)