From cbae6d09113ff3ff6c07af2ae341b7384fa97667 Mon Sep 17 00:00:00 2001 From: tadf Date: Sun, 21 Sep 2008 12:21:32 +0000 Subject: * complex.c: added two macros. * rational.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- rational.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'rational.c') diff --git a/rational.c b/rational.c index fea6f63ab8..3b352ea9da 100644 --- a/rational.c +++ b/rational.c @@ -167,6 +167,8 @@ f_negative_p(VALUE x) return rb_funcall(x, '<', 1, ZERO); } +#define f_positive_p(x) (!f_negative_p(x)) + inline static VALUE f_zero_p(VALUE x) { @@ -175,6 +177,8 @@ f_zero_p(VALUE x) return rb_funcall(x, id_equal_p, 1, ZERO); } +#define f_nonzero_p(x) (!f_zero_p(x)) + inline static VALUE f_one_p(VALUE x) { @@ -280,7 +284,7 @@ inline static VALUE f_gcd(VALUE x, VALUE y) { VALUE r = f_gcd_orig(x, y); - if (!f_zero_p(r)) { + if (f_nonzero_p(r)) { assert(f_zero_p(f_mod(x, r))); assert(f_zero_p(f_mod(y, r))); } @@ -366,8 +370,8 @@ f_rational_new_bang1(VALUE klass, VALUE x) inline static VALUE f_rational_new_bang2(VALUE klass, VALUE x, VALUE y) { - assert(!f_negative_p(y)); - assert(!f_zero_p(y)); + assert(f_positive_p(y)); + assert(f_nonzero_p(y)); return nurat_s_new_internal(klass, x, y); } @@ -955,7 +959,7 @@ nurat_quotrem(VALUE self, VALUE other) static VALUE nurat_abs(VALUE self) { - if (!f_negative_p(self)) + if (f_positive_p(self)) return self; return f_negate(self); } -- cgit v1.2.3