<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -25,8 +25,6 @@ VALUE rb_cNSArray0;
 VALUE rb_cNSArray;
 VALUE rb_cNSMutableArray;
 
-static ID id_cmp;
-
 #define ARY_DEFAULT_SIZE 16
 
 void
@@ -1536,19 +1534,17 @@ sort_1(const void *ap, const void *bp, void *dummy)
 static int
 sort_2(const void *ap, const void *bp, void *dummy)
 {
-    VALUE retval;
     VALUE a = (VALUE)ap, b = (VALUE)bp;
-    int n;
 
     /* FIXME optimize!!! */
     if (TYPE(a) == T_STRING) {
-	if (TYPE(b) == T_STRING) return rb_str_cmp(a, b);
+	if (TYPE(b) == T_STRING) {
+	    return rb_str_cmp(a, b);
+	}
     }
 
-    retval = rb_funcall(a, id_cmp, 1, b);
-    n = rb_cmpint(retval, a, b);
-
-    return n;
+    VALUE retval = rb_objs_cmp(a, b);
+    return rb_cmpint(retval, a, b);
 }
 
 /*
@@ -2546,7 +2542,7 @@ recursive_cmp(VALUE ary1, VALUE ary2, int recur)
 	len = RARRAY_LEN(ary2);
     }
     for (i=0; i&lt;len; i++) {
-	VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
+	VALUE v = rb_objs_cmp(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i));
 	if (v != INT2FIX(0)) {
 	    return v;
 	}
@@ -3814,6 +3810,4 @@ Init_Array(void)
     /* to return mutable copies */
     rb_objc_define_method(rb_cArray, &quot;dup&quot;, rb_ary_dup_imp, 0);
     rb_objc_define_method(rb_cArray, &quot;clone&quot;, rb_ary_clone, 0);
-
-    id_cmp = rb_intern(&quot;&lt;=&gt;&quot;);
 }</diff>
      <filename>array.c</filename>
    </modified>
    <modified>
      <diff>@@ -34,14 +34,24 @@ rb_cmperr(VALUE x, VALUE y)
 	     rb_obj_classname(x), classname);
 }
 
+VALUE
+rb_objs_cmp(VALUE x, VALUE y)
+{
+    return rb_vm_call_with_cache(cmp_cache, x, cmp, 1, &amp;y);
+}
+
 static VALUE
 cmp_eq(VALUE *a)
 {
     //VALUE c = rb_funcall(a[0], cmp, 1, a[1]);
     VALUE c = rb_vm_call_with_cache(cmp_cache, a[0], cmp, 1, &amp;a[1]);
 
-    if (NIL_P(c)) return Qfalse;
-    if (rb_cmpint(c, a[0], a[1]) == 0) return Qtrue;
+    if (NIL_P(c)) {
+	return Qfalse;
+    }
+    if (rb_cmpint(c, a[0], a[1]) == 0) {
+	return Qtrue;
+    }
     return Qfalse;
 }
 </diff>
      <filename>compar.c</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@
 #include &quot;id.h&quot;
 
 VALUE rb_mEnumerable;
-static ID id_each, id_eqq, id_cmp, id_next, id_size;
+static ID id_each, id_eqq, id_next, id_size;
 
 static VALUE
 enum_values_pack(int argc, VALUE *argv)
@@ -716,7 +716,7 @@ sort_by_cmp(const void *ap, const void *bp, void *data)
 	rb_raise(rb_eRuntimeError, &quot;sort_by reentered&quot;);
     }
 #endif
-    return rb_cmpint(rb_funcall(a, id_cmp, 1, b), a, b);
+    return rb_cmpint(rb_objs_cmp(a, b), a, b);
 }
 
 /*
@@ -996,7 +996,7 @@ min_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
 	*memo = i;
     }
     else {
-	cmp = rb_funcall(i, id_cmp, 1, *memo);
+	cmp = rb_objs_cmp(i, *memo);
 	if (rb_cmpint(cmp, i, *memo) &lt; 0) {
 	    *memo = i;
 	}
@@ -1069,7 +1069,7 @@ max_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
 	*memo = i;
     }
     else {
-	cmp = rb_funcall(i, id_cmp, 1, *memo);
+	cmp = rb_objs_cmp(i, *memo);
 	if (rb_cmpint(cmp, i, *memo) &gt; 0) {
 	    *memo = i;
 	}
@@ -1142,11 +1142,11 @@ minmax_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
 	memo[1] = i;
     }
     else {
-	n = rb_cmpint(rb_funcall(i, id_cmp, 1, memo[0]), i, memo[0]);
+	n = rb_cmpint(rb_objs_cmp(i, memo[0]), i, memo[0]);
 	if (n &lt; 0) {
 	    memo[0] = i;
 	}
-	n = rb_cmpint(rb_funcall(i, id_cmp, 1, memo[1]), i, memo[1]);
+	n = rb_cmpint(rb_objs_cmp(i, memo[1]), i, memo[1]);
 	if (n &gt; 0) {
 	    memo[1] = i;
 	}
@@ -1232,7 +1232,7 @@ min_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
 	memo[0] = v;
 	memo[1] = i;
     }
-    else if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo[0]), v, memo[0]) &lt; 0) {
+    else if (rb_cmpint(rb_objs_cmp(v, memo[0]), v, memo[0]) &lt; 0) {
 	memo[0] = v;
 	memo[1] = i;
     }
@@ -1275,7 +1275,7 @@ max_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
 	memo[0] = v;
 	memo[1] = i;
     }
-    else if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo[0]), v, memo[0]) &gt; 0) {
+    else if (rb_cmpint(rb_objs_cmp(v, memo[0]), v, memo[0]) &gt; 0) {
 	memo[0] = v;
 	memo[1] = i;
     }
@@ -1321,11 +1321,11 @@ minmax_by_i(VALUE i, VALUE *memo, int argc, VALUE *argv)
 	memo[3] = i;
     }
     else {
-	if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo[0]), v, memo[0]) &lt; 0) {
+	if (rb_cmpint(rb_objs_cmp(v, memo[0]), v, memo[0]) &lt; 0) {
 	    memo[0] = v;
 	    memo[2] = i;
 	}
-	if (rb_cmpint(rb_funcall(v, id_cmp, 1, memo[1]), v, memo[1]) &gt; 0) {
+	if (rb_cmpint(rb_objs_cmp(v, memo[1]), v, memo[1]) &gt; 0) {
 	    memo[1] = v;
 	    memo[3] = i;
 	}
@@ -1862,7 +1862,6 @@ Init_Enumerable(void)
 
     id_eqq  = rb_intern(&quot;===&quot;);
     id_each = rb_intern(&quot;each&quot;);
-    id_cmp  = rb_intern(&quot;&lt;=&gt;&quot;);
     id_next = rb_intern(&quot;next&quot;);
     id_size = rb_intern(&quot;size&quot;);
 }</diff>
      <filename>enum.c</filename>
    </modified>
    <modified>
      <diff>@@ -178,6 +178,7 @@ VALUE rb_singleton_class(VALUE);
 /* compar.c */
 int rb_cmpint(VALUE, VALUE, VALUE);
 NORETURN(void rb_cmperr(VALUE, VALUE));
+VALUE rb_objs_cmp(VALUE x, VALUE y);
 /* cont.c */
 VALUE rb_fiber_new(VALUE (*)(ANYARGS), VALUE);
 VALUE rb_fiber_resume(VALUE fib, int argc, VALUE *args);</diff>
      <filename>include/ruby/intern.h</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@
 #include &quot;id.h&quot;
 
 VALUE rb_cRange;
-static ID id_cmp, id_succ, id_beg, id_end, id_excl;
+static ID id_succ, id_beg, id_end, id_excl;
 static SEL selUpto = 0;
 static void *cacheUpto = NULL;
 
@@ -37,7 +37,7 @@ range_failed(void)
 static VALUE
 range_check(VALUE *args)
 {
-    return rb_funcall(args[0], id_cmp, 1, args[1]);
+    return rb_objs_cmp(args[0], args[1]);
 }
 
 static void
@@ -144,7 +144,7 @@ range_eq(VALUE range, SEL sel, VALUE obj)
 static int
 r_lt(VALUE a, VALUE b)
 {
-    VALUE r = rb_funcall(a, id_cmp, 1, b);
+    VALUE r = rb_objs_cmp(a, b);
 
     if (NIL_P(r))
 	return Qfalse;
@@ -157,7 +157,7 @@ static int
 r_le(VALUE a, VALUE b)
 {
     int c;
-    VALUE r = rb_funcall(a, id_cmp, 1, b);
+    VALUE r = rb_objs_cmp(a, b);
 
     if (NIL_P(r))
 	return Qfalse;
@@ -552,7 +552,7 @@ range_min(VALUE range, SEL sel)
     else {
 	VALUE b = RANGE_BEG(range);
 	VALUE e = RANGE_END(range);
-	int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);
+	int c = rb_cmpint(rb_objs_cmp(b, e), b, e);
 
 	if (c &gt; 0 || (c == 0 &amp;&amp; EXCL(range)))
 	    return Qnil;
@@ -587,7 +587,7 @@ range_max(VALUE range, SEL sel)
     }
     else {
 	VALUE b = RANGE_BEG(range);
-	int c = rb_cmpint(rb_funcall(b, id_cmp, 1, e), b, e);
+	int c = rb_cmpint(rb_objs_cmp(b, e), b, e);
 
 	if (c &gt; 0)
 	    return Qnil;
@@ -918,7 +918,6 @@ range_alloc(VALUE klass)
 void
 Init_Range(void)
 {
-    id_cmp = rb_intern(&quot;&lt;=&gt;&quot;);
     id_succ = rb_intern(&quot;succ&quot;);
     id_beg = rb_intern(&quot;begin&quot;);
     id_end = rb_intern(&quot;end&quot;);</diff>
      <filename>range.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4d7471d3921c1559a49f4c64b3e5a60529f9afa7</id>
    </parent>
  </parents>
  <author>
    <name>lsansonetti@apple.com</name>
    <email>lsansonetti@apple.com@23306eb0-4c56-4727-a40e-e92c0eb68959</email>
  </author>
  <url>http://github.com/masterkain/macruby/commit/92e42914b8aed8638424b17aeaf9a0c49ba03529</url>
  <id>92e42914b8aed8638424b17aeaf9a0c49ba03529</id>
  <committed-date>2009-07-07T19:52:12-07:00</committed-date>
  <authored-date>2009-07-07T19:52:12-07:00</authored-date>
  <message>optimized dummy calls to &lt;=&gt;:

git-svn-id: http://svn.macosforge.org/repository/ruby/MacRuby/branches/experimental@2001 23306eb0-4c56-4727-a40e-e92c0eb68959</message>
  <tree>40ebb3e26db685bc29eb5a7ab6b3b5af4b3d146d</tree>
  <committer>
    <name>lsansonetti@apple.com</name>
    <email>lsansonetti@apple.com@23306eb0-4c56-4727-a40e-e92c0eb68959</email>
  </committer>
</commit>
