Skip to content

Commit

Permalink
Some small optimizations and improvements to benchmark code.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Dec 8, 2011
1 parent 06ac7d3 commit efc28a7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
5 changes: 4 additions & 1 deletion actionpack/examples/performance.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ENV['RAILS_ENV'] ||= 'production'
ENV['NO_RELOAD'] ||= '1'

require File.expand_path('../../../load_paths', __FILE__)
require 'action_pack'
Expand Down Expand Up @@ -77,6 +76,10 @@ def self.done
end
end

ActionController::Base.logger = nil
ActionController::Base.config.compile_methods!
ActionView::Resolver.caching = ENV["RAILS_ENV"] == "production"

class BasePostController < ActionController::Base
append_view_path "#{File.dirname(__FILE__)}/views"

Expand Down
7 changes: 1 addition & 6 deletions actionpack/lib/abstract_controller/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ def protected_instance_variables
end

def view_context_class
@_view_context_class || self.class.view_context_class
end

def initialize(*)
@_view_context_class = nil
super
@_view_context_class ||= self.class.view_context_class
end

# An instance of a view class. The default view class is ActionView::Base
Expand Down
18 changes: 9 additions & 9 deletions actionpack/lib/action_view/lookup_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class LookupContext #:nodoc:

def self.register_detail(name, options = {}, &block)
self.registered_details << name
initialize = registered_details.map { |n| "self.#{n} = details[:#{n}]" }
initialize = registered_details.map { |n| "@details[:#{n}] = details[:#{n}] || default_#{n}" }

Accessors.send :define_method, :"default_#{name}", &block
Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
Expand All @@ -29,7 +29,7 @@ def #{name}
end
def #{name}=(value)
value = Array.wrap(value.presence || default_#{name})
value = value.present? ? Array.wrap(value) : default_#{name}
_set_detail(:#{name}, value) if value != @details[:#{name}]
end
Expand Down Expand Up @@ -153,14 +153,14 @@ def normalize_name(name, prefixes) #:nodoc:
""
end

parts = name.split('/')
name = parts.pop
prefixes = nil if prefixes.blank?
parts = name.split('/')
name = parts.pop

prefixes = if prefixes.blank?
[parts.join('/')]
else
prefixes.map { |prefix| [prefix, *parts].compact.join('/') }
end
return name, prefixes || [""] if parts.empty?

parts = parts.join('/')
prefixes = prefixes ? prefixes.map { |p| "#{p}/#{parts}" } : [parts]

return name, prefixes
end
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/template/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def initialize(name, prefix, partial, virtual)
end
end

cattr_accessor :caching
class_attribute :caching
self.caching = true

class << self
Expand Down

0 comments on commit efc28a7

Please sign in to comment.