diff options
author | Rafaël Blais Masson <rafbmasson@gmail.com> | 2015-12-30 14:34:17 -0500 |
---|---|---|
committer | Rafaël Blais Masson <rafbmasson@gmail.com> | 2015-12-30 14:36:32 -0500 |
commit | 040ed26656589b9e61dbb05cd57476b7c4a5b807 (patch) | |
tree | 3d5f042e895f28d105224eaa7ba3dec884ed235e | |
parent | f390bd42b8fec6423567e782a2716bda95295f9d (diff) | |
download | rails-040ed26656589b9e61dbb05cd57476b7c4a5b807.tar.gz rails-040ed26656589b9e61dbb05cd57476b7c4a5b807.tar.bz2 rails-040ed26656589b9e61dbb05cd57476b7c4a5b807.zip |
Avoid `Time.parse` for static date
Benchmark.ips do |x|
x.report('Time.parse') { Time.parse('2011-01-01') }
x.report('Time.new') { Time.new(2011, 1, 1) }
end
Calculating -------------------------------------
Time.parse 6.640k i/100ms
Time.new 15.082k i/100ms
-------------------------------------------------
Time.parse 71.915k (± 3.1%) i/s - 365.200k
Time.new 167.645k (± 3.3%) i/s - 844.592k
-rw-r--r-- | actionpack/lib/action_controller/metal/conditional_get.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb index d86a793e4c..f8e0d9cf6c 100644 --- a/actionpack/lib/action_controller/metal/conditional_get.rb +++ b/actionpack/lib/action_controller/metal/conditional_get.rb @@ -228,7 +228,7 @@ module ActionController expires_in 100.years, public: public yield if stale?(etag: "#{version}-#{request.fullpath}", - last_modified: Time.parse('2011-01-01').utc, + last_modified: Time.new(2011, 1, 1).utc, public: public) end |