We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf8c689 commit a5c13beCopy full SHA for a5c13be
lib/bson/timestamp.rb
@@ -70,15 +70,10 @@ def ==(other)
70
# @since 4.3.0
71
def <=>(other)
72
raise ArgumentError.new(COMPARISON_ERROR_MESSAGE % other.class) unless other.is_a?(Timestamp)
73
- time = seconds + increment
74
- other_time = other.seconds + other.increment
75
- if time < other_time
76
- -1
77
- elsif time > other_time
78
- 1
79
- else
80
- 0
81
- end
+ return 0 if self == other
+ a = [ seconds, increment ]
+ b = [ other.seconds, other.increment ]
+ [ a, b ].sort[0] == a ? -1 : 1
82
end
83
84
# Get the timestamp as JSON hash data.
0 commit comments