From f28caf31d17cff9aa84b3fca6e7631950c1d9338 Mon Sep 17 00:00:00 2001
From: nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Fri, 28 Oct 2016 07:05:05 +0000
Subject: insns.def: opt_case_dispatch trivial optimization

* insns.def (opt_case_dispatch): extract float value only if the
  Float method is not redefnined.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 insns.def | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

(limited to 'insns.def')

diff --git a/insns.def b/insns.def
index ac53f967c1..ecd60f02f3 100644
--- a/insns.def
+++ b/insns.def
@@ -1327,18 +1327,10 @@ opt_case_dispatch
 (..., 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
 				   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;
     }
 }
 
-- 
cgit v1.2.3

