Only coerce time when comparing if necessary
In dev, ActiveSupport::FileUpdateChecker#max_mtime triggers many time comparisons. Time#to_time is quite a bit slower than not doing it, so we should avoid it if possible.
This commit is contained in:
parent
baa176e3f0
commit
97698606de
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user