提交 e3e28e4d 编写于 作者: R Rafael Mendonça França

Merge pull request #19604 from aaronjensen/speed-up-time-coercion

Only coerce time when comparing if necessary
......@@ -246,8 +246,10 @@ def minus_with_coercion(other)
# Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances
# can be chronologically compared with a Time
def compare_with_coercion(other)
# we're avoiding Time#to_datetime cause it's expensive
if other.is_a?(Time)
# we're avoiding Time#to_datetime and Time#to_time because they're expensive
if other.class == Time
compare_without_coercion(other)
elsif other.is_a?(Time)
compare_without_coercion(other.to_time)
else
to_datetime <=> other
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册