Skip to content
This repository
Browse code

range optimization from @monaka; close #348

  • Loading branch information...
commit 84ec555ecd4b51767b695d0367d4dbe321359f30 1 parent dfaa5c9
Yukihiro "Matz" Matsumoto authored July 06, 2012

Showing 1 changed file with 4 additions and 4 deletions. Show diff stats Hide diff stats

  1. 8  src/range.c
8  src/range.c
@@ -185,14 +185,14 @@ mrb_range_eq(mrb_state *mrb, mrb_value range)
185 185
 static int
186 186
 r_le(mrb_state *mrb, mrb_value a, mrb_value b)
187 187
 {
188  
-  //int c;
189 188
   mrb_value r = mrb_funcall(mrb, a, "<=>", 1, b); /* compare result */
190 189
   /* output :a < b => -1, a = b =>  0, a > b => +1 */
191 190
 
192  
-  if (mrb_nil_p(r)) return FALSE;
  191
+  if (mrb_type(r) == MRB_TT_FIXNUM) {
  192
+    int c = mrb_fixnum(r);
  193
+    if (c == 0 || c == -1) return TRUE;
  194
+  }
193 195
 
194  
-  if (mrb_obj_equal(mrb, r, mrb_fixnum_value(0))) return TRUE;
195  
-  if (mrb_obj_equal(mrb, r, mrb_fixnum_value(-1))) return TRUE;
196 196
   return FALSE;
197 197
 }
198 198
 

0 notes on commit 84ec555

Please sign in to comment.
Something went wrong with that request. Please try again.