diff options
author | Dillon Welch <daw0328@gmail.com> | 2018-03-29 19:29:55 -0700 |
---|---|---|
committer | Dillon Welch <daw0328@gmail.com> | 2018-07-23 15:37:06 -0700 |
commit | d108288c2f684233298f97f18ac00de0b016deaa (patch) | |
tree | 0656fd6f20d662d854a3fc93e80dfbc0baec063d /railties/lib | |
parent | a4398e412c042b297039cc216f6536b0c048bd9c (diff) | |
download | rails-d108288c2f684233298f97f18ac00de0b016deaa.tar.gz rails-d108288c2f684233298f97f18ac00de0b016deaa.tar.bz2 rails-d108288c2f684233298f97f18ac00de0b016deaa.zip |
Turn on performance based cops
Use attr_reader/attr_writer instead of methods
method is 12% slower
Use flat_map over map.flatten(1)
flatten is 66% slower
Use hash[]= instead of hash.merge! with single arguments
merge! is 166% slower
See https://github.com/rails/rails/pull/32337 for more conversation
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/configuration.rb | 8 | ||||
-rw-r--r-- | railties/lib/rails/generators.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/generators/actions.rb | 2 |
5 files changed, 6 insertions, 18 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index e346d5cc3a..bc5cd230fc 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -373,9 +373,7 @@ module Rails @config ||= Application::Configuration.new(self.class.find_root(self.class.called_from)) end - def config=(configuration) #:nodoc: - @config = configuration - end + attr_writer :config # Returns secrets added to config/secrets.yml. # @@ -413,9 +411,7 @@ module Rails end end - def secrets=(secrets) #:nodoc: - @secrets = secrets - end + attr_writer :secrets # The secret_key_base is used as the input secret to the application's key generator, which in turn # is used to create all MessageVerifiers/MessageEncryptors, including the ones that sign and encrypt cookies. diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index bba573499d..9c54cc1f37 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -146,9 +146,7 @@ module Rails @debug_exception_response_format || :default end - def debug_exception_response_format=(value) - @debug_exception_response_format = value - end + attr_writer :debug_exception_response_format def paths @paths ||= begin diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index d3a54d9364..e8741a50ba 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -79,13 +79,7 @@ module Rails end protected - def operations - @operations - end - - def delete_operations - @delete_operations - end + attr_reader :operations, :delete_operations end class Generators #:nodoc: diff --git a/railties/lib/rails/generators.rb b/railties/lib/rails/generators.rb index 2a41403557..ed672ae48e 100644 --- a/railties/lib/rails/generators.rb +++ b/railties/lib/rails/generators.rb @@ -126,7 +126,7 @@ module Rails ) if ARGV.first == "mailer" - options[:rails].merge!(template_engine: :erb) + options[:rails][:template_engine] = :erb end end diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index d85bbfb03e..ae395708cb 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -298,7 +298,7 @@ module Rails sudo = options[:sudo] && !Gem.win_platform? ? "sudo " : "" config = { verbose: false } - config.merge!(capture: options[:capture]) if options[:capture] + config[:capture] = options[:capture] if options[:capture] in_root { run("#{sudo}#{extify(executor)} #{command} RAILS_ENV=#{env}", config) } end |