pvalena / rpms / ruby

Forked from rpms/ruby 6 years ago
Clone
5961c79
From 0b89d6d5f9f8c788f4391d8a0499f10aed624371 Mon Sep 17 00:00:00 2001
5961c79
From: ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
5961c79
Date: Mon, 27 Aug 2012 09:22:21 +0000
5961c79
Subject: [PATCH] * include/ruby/ruby.h (rb_float_value): optimize it.   This
5961c79
 technique was pointed by shinichiro.hamaji  
5961c79
 <http://shinh.skr.jp/m/?date=20120825#p02>.
5961c79
5961c79
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
5961c79
---
5961c79
 ChangeLog           |    6 ++++++
5961c79
 include/ruby/ruby.h |   10 +++++-----
5961c79
 2 files changed, 11 insertions(+), 5 deletions(-)
5961c79
5961c79
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
5961c79
index 3905b32..b8b2267 100644
5961c79
--- a/include/ruby/ruby.h
5961c79
+++ b/include/ruby/ruby.h
5961c79
@@ -733,10 +733,7 @@ struct RFloat {
5961c79
 rb_float_value(VALUE v)
5961c79
 {
5961c79
     if (FLONUM_P(v)) {
5961c79
-	if (v == (VALUE)0x8000000000000002) {
5961c79
-	    return 0.0;
5961c79
-	}
5961c79
-	else {
5961c79
+	if (v != (VALUE)0x8000000000000002) { /* LIKELY */
5961c79
 	    union {
5961c79
 		double d;
5961c79
 		VALUE v;
5961c79
@@ -746,9 +743,12 @@ struct RFloat {
5961c79
 	    /* e: xx1... -> 011... */
5961c79
 	    /*    xx0... -> 100... */
5961c79
 	    /*      ^b63           */
5961c79
-	    t.v = RUBY_BIT_ROTR(((b63 ^ 1) << 1) | b63 | (v & ~0x03), 3);
5961c79
+	    t.v = RUBY_BIT_ROTR(2 - b63 | (v & ~0x03), 3);
5961c79
 	    return t.d;
5961c79
 	}
5961c79
+	else {
5961c79
+	    return 0.0;
5961c79
+	}
5961c79
     }
5961c79
     else {
5961c79
 	return ((struct RFloat *)v)->float_value;
5961c79
-- 
5961c79
1.7.10
5961c79