From 74cdd893eb102ba98e735f2a24c710e1928261a9 Mon Sep 17 00:00:00 2001 From: shyouhei Date: Mon, 6 Mar 2017 11:14:05 +0000 Subject: optimize FIXABLE macro Looking at the source code, FIXABLE tends to be just before LOING2FIX to check applicability of that operation. Why not try computing first then check for overflow, which should be optimial. I also tried the same thing for unsigned types but resulted in slower execution. It seems RB_POSFIXABLE() is fast enough on modern CPUs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57789 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compile.c') diff --git a/compile.c b/compile.c index f1ba0946b3..835fa41414 100644 --- a/compile.c +++ b/compile.c @@ -3190,7 +3190,7 @@ case_when_optimizable_literal(NODE *node) double ival; if (RB_TYPE_P(v, T_FLOAT) && modf(RFLOAT_VALUE(v), &ival) == 0.0) { - return FIXABLE(ival) ? LONG2FIX((long)ival) : rb_dbl2big(ival); + return rb_dbl2ival(ival); } if (SYMBOL_P(v) || rb_obj_is_kind_of(v, rb_cNumeric)) { return v; -- cgit v1.2.3