Skip to content
This repository
Browse code

Fix <=, ==, >= comparisons to avoid trivial object identity comparisons.

  • Loading branch information...
commit aaf7cc806a0d8b73c7a8e1601a69ccd960aa5033 1 parent 4e68d7a
Charles Oliver Nutter headius authored

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

  1. +8 6 benchmark/core/time/bench_comparable.rb
14 benchmark/core/time/bench_comparable.rb
@@ -7,8 +7,10 @@
7 7
8 8 temp = $small_time_float_array.sort
9 9 fixnum_time = Time.at(temp[0].to_i)
  10 + fixnum_time2 = Time.at(temp[0].to_i)
10 11
11 12 float_time = temp[0]
  13 + float_time2 = temp[0]
12 14
13 15 x.compare!
14 16
@@ -23,7 +25,7 @@
23 25 x.report "time <= time, (fixnum <=> fixnum)" do |times|
24 26 i = 0
25 27 while i < times
26   - fixnum_time <= fixnum_time
  28 + fixnum_time <= fixnum_time2
27 29 i += 1
28 30 end
29 31 end
@@ -31,7 +33,7 @@
31 33 x.report "time == time, (fixnum <=> fixnum)" do |times|
32 34 i = 0
33 35 while i < times
34   - fixnum_time == fixnum_time
  36 + fixnum_time == fixnum_time2
35 37 i += 1
36 38 end
37 39 end
@@ -39,7 +41,7 @@
39 41 x.report "time >= time, (fixnum <=> fixnum)" do |times|
40 42 i = 0
41 43 while i < times
42   - fixnum_time >= fixnum_time
  44 + fixnum_time >= fixnum_time2
43 45 i += 1
44 46 end
45 47 end
@@ -63,7 +65,7 @@
63 65 x.report "time <= time, (float <=> float)" do |times|
64 66 i = 0
65 67 while i < times
66   - float_time <= float_time
  68 + float_time <= float_time2
67 69 i += 1
68 70 end
69 71 end
@@ -71,7 +73,7 @@
71 73 x.report "time == time, (float <=> float)" do |times|
72 74 i = 0
73 75 while i < times
74   - float_time == float_time
  76 + float_time == float_time2
75 77 i += 1
76 78 end
77 79 end
@@ -79,7 +81,7 @@
79 81 x.report "time >= time, (float <=> float)" do |times|
80 82 i = 0
81 83 while i < times
82   - float_time >= float_time
  84 + float_time >= float_time2
83 85 i += 1
84 86 end
85 87 end

0 comments on commit aaf7cc8

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