aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2016-10-06 02:35:35 +1030
committerGitHub <noreply@github.com>2016-10-06 02:35:35 +1030
commit0464b728e2e90623da52301fe1cec19e5c600691 (patch)
tree574e2d30fba971d5e31b142c339a482488891c24 /activesupport
parent161b6079b55ed50d451d8be15b7fca14a870568e (diff)
parent353122c9da6caa30f1d4a117d4c543cd567ca3bb (diff)
downloadrails-0464b728e2e90623da52301fe1cec19e5c600691.tar.gz
rails-0464b728e2e90623da52301fe1cec19e5c600691.tar.bz2
rails-0464b728e2e90623da52301fe1cec19e5c600691.zip
Merge pull request #26359 from maclover7/jm-speed-up-time
Speed up Time.zone.now
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/time_with_zone.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb
index 8de8120fba..889f71c4f3 100644
--- a/activesupport/lib/active_support/time_with_zone.rb
+++ b/activesupport/lib/active_support/time_with_zone.rb
@@ -477,6 +477,8 @@ module ActiveSupport
end
def transfer_time_values_to_utc_constructor(time)
+ # avoid creating another Time object if possible
+ return time if time.instance_of?(::Time) && time.utc?
::Time.utc(time.year, time.month, time.day, time.hour, time.min, time.sec + time.subsec)
end