[#237] object.c ruby.h (fwd) — Robert Skarwecki <skaav@...>

Hello everybody,

42 messages 2002/07/24
[#239] Re: [PATCH] object.c ruby.h (fwd) — GOTO Kentaro <gotoken@...> 2002/07/24

At Thu, 25 Jul 2002 00:02:28 +0900,

[#240] Re: [PATCH] object.c ruby.h (fwd) — Dave Thomas <Dave@...> 2002/07/24

GOTO Kentaro <gotoken@notwork.org> writes:

[#246] Re: [PATCH] object.c ruby.h (fwd) — GOTO Kentaro <gotoken@...> 2002/07/25

At Thu, 25 Jul 2002 05:05:46 +0900,

[#247] Re: [PATCH] object.c ruby.h (fwd) — Dave Thomas <Dave@...> 2002/07/25

GOTO Kentaro <gotoken@notwork.org> writes:

[#248] Re: [PATCH] object.c ruby.h (fwd) — nobu.nokada@... 2002/07/25

Hi,

[#249] Re: [PATCH] object.c ruby.h (fwd) — Dave Thomas <Dave@...> 2002/07/25

nobu.nokada@softhome.net writes:

[#250] Re: [PATCH] object.c ruby.h (fwd) — nobu.nokada@... 2002/07/25

Hi,

[#252] Re: [PATCH] object.c ruby.h (fwd) — GOTO Kentaro <gotoken@...> 2002/07/25

At Fri, 26 Jul 2002 03:11:02 +0900,

[#253] Re: [PATCH] object.c ruby.h (fwd) — Dave Thomas <Dave@...> 2002/07/25

GOTO Kentaro <gotoken@notwork.org> writes:

[Patch] Tini mini Range cleanup

From: Michal Rokos <m.rokos@...>
Date: 2002-07-30 08:54:34 UTC
List: ruby-core #276
Hi,

	there is nearly nothing to say about. Just 1 LONG2FIX conv, 1
	arg. declaration, and 2 not needed funcalls.

	Worth it to merge it?

		Michal


Index: range.c
===================================================================
RCS file: /src/ruby/range.c,v
retrieving revision 1.41
diff -u -r1.41 range.c
--- range.c	2002/07/02 09:58:13	1.41
+++ range.c	2002/07/30 08:50:06
@@ -16,7 +16,7 @@
 static ID id_cmp, id_succ, id_beg, id_end, id_excl;
 
 #define EXCL(r) RTEST(rb_ivar_get((r), id_excl))
-#define SET_EXCL(r,v) rb_ivar_set((r), id_excl, (v)?Qtrue:Qfalse)
+#define SET_EXCL(r,v) rb_ivar_set((r), id_excl, (v) ? Qtrue : Qfalse)
 
 static VALUE
 range_check(args)
@@ -43,7 +43,9 @@
 {
     VALUE args[2];
 
-    args[0] = beg; args[1] = end;
+    args[0] = beg;
+    args[1] = end;
+    
     if (!FIXNUM_P(beg) || !FIXNUM_P(end)) {
 	rb_rescue(range_check, (VALUE)args, range_failed, 0);
     }
@@ -85,7 +87,7 @@
 range_exclude_end_p(range)
     VALUE range;
 {
-    return EXCL(range)?Qtrue:Qfalse;
+    return EXCL(range) ? Qtrue : Qfalse;
 }
 
 static VALUE
@@ -176,7 +178,7 @@
     hash ^= v << 9;
     hash ^= EXCL(range) << 24;
 
-    return INT2FIX(hash);
+    return LONG2FIX(hash);
 }
 
 static VALUE
@@ -203,11 +205,11 @@
 range_each_func(range, func, v, e, arg)
     VALUE range;
     void (*func) _((VALUE, void*));
+    VALUE v, e;
     void *arg;
 {
     if (EXCL(range)) {
 	while (r_lt(v, e)) {
-	    if (r_eq(v, e)) break;
 	    (*func)(v, arg);
 	    v = rb_funcall(v, id_succ, 0, 0);
 	}
@@ -215,7 +217,6 @@
     else {
 	while (r_le(v, e)) {
 	    (*func)(v, arg);
-	    if (r_eq(v, e)) break;
 	    v = rb_funcall(v, id_succ, 0, 0);
 	}
     }
@@ -272,6 +273,7 @@
 	    rb_raise(rb_eTypeError, "cannot iterate from %s",
 		     rb_class2name(CLASS_OF(b)));
 	}
+	
 	args[0] = 1;
 	args[1] = unit;
 	range_each_func(range, step_i, b, e, args);

-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Michal Rokos                         Czech Technical University, Prague
E-mail:m.rokos@sh.cvut.cz      ICQ:36118339      Jabber:majkl@jabber.cz
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

In This Thread

Prev Next