ruby-changes:44438
From: nobu <ko1@a...>
Date: Fri, 28 Oct 2016 16:05:09 +0900 (JST)
Subject: [ruby-changes:44438] nobu:r56511 (trunk): insns.def: opt_case_dispatch trivial optimization
nobu 2016-10-28 16:05:05 +0900 (Fri, 28 Oct 2016) New Revision: 56511 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56511 Log: insns.def: opt_case_dispatch trivial optimization * insns.def (opt_case_dispatch): extract float value only if the Float method is not redefnined. Modified files: trunk/ChangeLog trunk/insns.def Index: insns.def =================================================================== --- insns.def (revision 56510) +++ insns.def (revision 56511) @@ -1327,18 +1327,10 @@ opt_case_dispatch https://github.com/ruby/ruby/blob/trunk/insns.def#L1327 (..., VALUE key) () // inc += -1; { - switch(TYPE(key)) { - case T_FLOAT: { - double ival; - if (modf(RFLOAT_VALUE(key), &ival) == 0.0 && !isinf(ival)) { - key = FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival); - } - } - case T_TRUE: /* fall through */ - case T_FALSE: - case T_NIL: + switch (OBJ_BUILTIN_TYPE(key)) { + case -1: + case T_FLOAT: case T_SYMBOL: - case T_FIXNUM: case T_BIGNUM: case T_STRING: if (BASIC_OP_UNREDEFINED_P(BOP_EQQ, @@ -1350,16 +1342,19 @@ opt_case_dispatch https://github.com/ruby/ruby/blob/trunk/insns.def#L1342 FALSE_REDEFINED_OP_FLAG | STRING_REDEFINED_OP_FLAG)) { st_data_t val; + if (RB_FLOAT_TYPE_P(key)) { + double kval = RFLOAT_VALUE(key); + if (!isinf(kval) && modf(kval, &kval) == 0.0) { + key = FIXABLE(kval) ? LONG2FIX((long)kval) : rb_dbl2big(kval); + } + } if (st_lookup(RHASH_TBL_RAW(hash), key, &val)) { JUMP(FIX2INT((VALUE)val)); } else { JUMP(else_offset); } - break; } - default: - break; } } Index: ChangeLog =================================================================== --- ChangeLog (revision 56510) +++ ChangeLog (revision 56511) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Oct 28 16:05:03 2016 Nobuyoshi Nakada <nobu@r...> + + * insns.def (opt_case_dispatch): extract float value only if the + Float method is not redefnined. + Fri Oct 28 15:58:16 2016 Nobuyoshi Nakada <nobu@r...> * internal.h (RB_OBJ_BUILTIN_TYPE): special-const safe -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/