[前][次][番号順一覧][スレッド一覧]

ruby-changes:28750

From: akr <ko1@a...>
Date: Sat, 18 May 2013 09:02:26 +0900 (JST)
Subject: [ruby-changes:28750] akr:r40802 (trunk): * ext/socket/mkconstants.rb (INTEGER2VALUE): Use LONG2FIX if possible.

akr	2013-05-18 09:01:10 +0900 (Sat, 18 May 2013)

  New Revision: 40802

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40802

  Log:
    * ext/socket/mkconstants.rb (INTEGER2VALUE): Use LONG2FIX if possible.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/mkconstants.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40801)
+++ ChangeLog	(revision 40802)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 18 09:00:32 2013  Tanaka Akira  <akr@f...>
+
+	* ext/socket/mkconstants.rb (INTEGER2VALUE): Use LONG2FIX if possible.
+
 Sat May 18 00:38:47 2013  Tanaka Akira  <akr@f...>
 
 	* ext/socket/mkconstants.rb: Convert integer constants bigger than int
Index: ext/socket/mkconstants.rb
===================================================================
--- ext/socket/mkconstants.rb	(revision 40801)
+++ ext/socket/mkconstants.rb	(revision 40802)
@@ -280,9 +280,13 @@ result = ERB.new(<<'EOS', nil, '%').resu https://github.com/ruby/ruby/blob/trunk/ext/socket/mkconstants.rb#L280
 <%= INTERN_DEFS.map {|vardef, gen_hash, decl, func| vardef }.join("\n") %>
 
 #ifdef HAVE_LONG_LONG
-#define INTEGER2VALUE(n) ((n) <= 0 ? LL2NUM(n) : ULL2NUM(n))
+#define INTEGER2VALUE(n) (0 < (n) ? \
+    ((n) <= FIXNUM_MAX ? LONG2FIX(n) : ULL2NUM(n)) : \
+    (FIXNUM_MIN <= (n) ? LONG2FIX(n) : LL2NUM(n)))
 #else
-#define INTEGER2VALUE(n) ((n) <= 0 ? LONG2NUM(n) : ULONG2NUM(n))
+#define INTEGER2VALUE(n) (0 < (n) ? \
+    ((n) <= FIXNUM_MAX ? LONG2FIX(n) : ULONG2NUM(n)) : \
+    (FIXNUM_MIN <= (n) ? LONG2FIX(n) : LONG2NUM(n)))
 #endif
 
 static void

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]