summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-23 15:51:31 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-02-23 15:51:31 +0000
commit497fa6222e47837f2b8d19931589f03846c331fc (patch)
tree705c0f51b0940e2b3277a8c60b98f5e7bd21d472
parentec4fcf3c171ad5d4026663b2d241740040d9994c (diff)
downloadruby-497fa6222e47837f2b8d19931589f03846c331fc.tar.gz
ruby-497fa6222e47837f2b8d19931589f03846c331fc.tar.xz
ruby-497fa6222e47837f2b8d19931589f03846c331fc.zip
* math.c (Need_Float): call rb_to_float() only when it is really
needed. small performance improvement. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog3
-rw-r--r--math.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index e78c50ceb..aebe79fe7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@ Tue Feb 24 00:24:13 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (range_each): check #succ only when it is really
needed. small performance improvement.
+ * math.c (Need_Float): call rb_to_float() only when it is really
+ needed. small performance improvement.
+
Tue Feb 24 00:19:33 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* lib/pathname.rb (Pathname#foreachline): removed wrongly
diff --git a/math.c b/math.c
index 2043bebfe..cc557c960 100644
--- a/math.c
+++ b/math.c
@@ -16,7 +16,7 @@
VALUE rb_mMath;
extern VALUE rb_to_float(VALUE val);
-#define Need_Float(x) (x) = rb_to_float(x)
+#define Need_Float(x) do {if (TYPE(x) != T_FLOAT) {(x) = rb_to_float(x);}} while(0)
#define Need_Float2(x,y) do {\
Need_Float(x);\
Need_Float(y);\