mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merges r24511 from trunk into ruby_1_9_1.
-- * insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h: check definition of (classes)#=== for case/when optimization. Fix Bug #1376 [ruby-core:23190]. * string.c (Init_String), bignum.c (Init_Bignum), numeric.c (Init_Numeric): define String#===, Symbol#===, Bignum#===, Fixnum#===, Float#=== as same as (classes)#==. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3e26b95145
commit
0a84a18ef4
8 changed files with 50 additions and 4 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Wed Aug 12 Wed Aug 12 14:54:34 2009 Koichi Sasada <ko1@atdot.net>
|
||||
|
||||
* insns.def, vm.c, vm_insnhelper.c, vm_insnhelper.h: check
|
||||
definition of (classes)#=== for case/when optimization.
|
||||
Fix Bug #1376 [ruby-core:23190].
|
||||
|
||||
* string.c (Init_String), bignum.c (Init_Bignum),
|
||||
numeric.c (Init_Numeric): define String#===, Symbol#===,
|
||||
Bignum#===, Fixnum#===, Float#=== as same as (classes)#==.
|
||||
|
||||
Wed Aug 12 12:59:51 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_new_frozen): must not change encoding of frozen
|
||||
|
|
1
bignum.c
1
bignum.c
|
@ -2709,6 +2709,7 @@ Init_Bignum(void)
|
|||
|
||||
rb_define_method(rb_cBignum, "<=>", rb_big_cmp, 1);
|
||||
rb_define_method(rb_cBignum, "==", rb_big_eq, 1);
|
||||
rb_define_method(rb_cBignum, "===", rb_big_eq, 1);
|
||||
rb_define_method(rb_cBignum, "eql?", rb_big_eql, 1);
|
||||
rb_define_method(rb_cBignum, "hash", rb_big_hash, 0);
|
||||
rb_define_method(rb_cBignum, "to_f", rb_big_to_f, 0);
|
||||
|
|
19
insns.def
19
insns.def
|
@ -1237,10 +1237,7 @@ opt_case_dispatch
|
|||
(..., VALUE key)
|
||||
() // inc += -1;
|
||||
{
|
||||
if (0) {
|
||||
/* TODO: if some === method is overrided */
|
||||
}
|
||||
else {
|
||||
if (BASIC_OP_UNREDEFINED_P(BOP_EQQ)) {
|
||||
VALUE val;
|
||||
if (st_lookup(RHASH_TBL(hash), key, &val)) {
|
||||
JUMP(FIX2INT(val));
|
||||
|
@ -1249,6 +1246,20 @@ opt_case_dispatch
|
|||
JUMP(else_offset);
|
||||
}
|
||||
}
|
||||
else {
|
||||
struct opt_case_dispatch_i_arg arg = {
|
||||
key, -1
|
||||
};
|
||||
|
||||
st_foreach(RHASH_TBL(hash), opt_case_dispatch_i, &arg);
|
||||
|
||||
if (arg.label != -1) {
|
||||
JUMP(arg.label);
|
||||
}
|
||||
else {
|
||||
JUMP(else_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3163,6 +3163,7 @@ Init_Numeric(void)
|
|||
rb_define_method(rb_cFixnum, "magnitude", fix_abs, 0);
|
||||
|
||||
rb_define_method(rb_cFixnum, "==", fix_equal, 1);
|
||||
rb_define_method(rb_cFixnum, "===", fix_equal, 1);
|
||||
rb_define_method(rb_cFixnum, "<=>", fix_cmp, 1);
|
||||
rb_define_method(rb_cFixnum, ">", fix_gt, 1);
|
||||
rb_define_method(rb_cFixnum, ">=", fix_ge, 1);
|
||||
|
@ -3216,6 +3217,7 @@ Init_Numeric(void)
|
|||
rb_define_method(rb_cFloat, "divmod", flo_divmod, 1);
|
||||
rb_define_method(rb_cFloat, "**", flo_pow, 1);
|
||||
rb_define_method(rb_cFloat, "==", flo_eq, 1);
|
||||
rb_define_method(rb_cFloat, "===", flo_eq, 1);
|
||||
rb_define_method(rb_cFloat, "<=>", flo_cmp, 1);
|
||||
rb_define_method(rb_cFloat, ">", flo_gt, 1);
|
||||
rb_define_method(rb_cFloat, ">=", flo_ge, 1);
|
||||
|
|
2
string.c
2
string.c
|
@ -7125,6 +7125,7 @@ Init_String(void)
|
|||
rb_define_method(rb_cString, "initialize_copy", rb_str_replace, 1);
|
||||
rb_define_method(rb_cString, "<=>", rb_str_cmp_m, 1);
|
||||
rb_define_method(rb_cString, "==", rb_str_equal, 1);
|
||||
rb_define_method(rb_cString, "===", rb_str_equal, 1);
|
||||
rb_define_method(rb_cString, "eql?", rb_str_eql, 1);
|
||||
rb_define_method(rb_cString, "hash", rb_str_hash_m, 0);
|
||||
rb_define_method(rb_cString, "casecmp", rb_str_casecmp, 1);
|
||||
|
@ -7254,6 +7255,7 @@ Init_String(void)
|
|||
rb_define_singleton_method(rb_cSymbol, "all_symbols", rb_sym_all_symbols, 0); /* in parse.y */
|
||||
|
||||
rb_define_method(rb_cSymbol, "==", sym_equal, 1);
|
||||
rb_define_method(rb_cSymbol, "===", sym_equal, 1);
|
||||
rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
|
||||
rb_define_method(rb_cSymbol, "to_s", rb_sym_to_s, 0);
|
||||
rb_define_method(rb_cSymbol, "id2name", rb_sym_to_s, 0);
|
||||
|
|
1
vm.c
1
vm.c
|
@ -948,6 +948,7 @@ vm_init_redefined_flag(void)
|
|||
OP(DIV, DIV), (C(Fixnum), C(Float));
|
||||
OP(MOD, MOD), (C(Fixnum), C(Float));
|
||||
OP(Eq, EQ), (C(Fixnum), C(Float), C(String));
|
||||
OP(Eqq, EQQ), (C(Fixnum), C(Bignum), C(Float), C(Symbol), C(String));
|
||||
OP(LT, LT), (C(Fixnum));
|
||||
OP(LE, LE), (C(Fixnum));
|
||||
OP(LTLT, LTLT), (C(String), C(Array));
|
||||
|
|
|
@ -1536,3 +1536,21 @@ opt_eq_func(VALUE recv, VALUE obj, IC ic)
|
|||
|
||||
return val;
|
||||
}
|
||||
|
||||
struct opt_case_dispatch_i_arg {
|
||||
VALUE obj;
|
||||
int label;
|
||||
};
|
||||
|
||||
static int
|
||||
opt_case_dispatch_i(st_data_t key, st_data_t data, struct opt_case_dispatch_i_arg *arg)
|
||||
{
|
||||
if (RTEST(rb_funcall((VALUE)key, idEqq, 1, arg->obj))) {
|
||||
arg->label = FIX2INT((VALUE)data);
|
||||
return ST_STOP;
|
||||
}
|
||||
else {
|
||||
return ST_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ enum {
|
|||
BOP_DIV,
|
||||
BOP_MOD,
|
||||
BOP_EQ,
|
||||
BOP_EQQ,
|
||||
BOP_LT,
|
||||
BOP_LE,
|
||||
BOP_LTLT,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue