Skip to content
This repository
Browse code

Some small optimizations and improvements to benchmark code.

  • Loading branch information...
commit efc28a7f701e518eb747c57712f6c1d8e7027aeb 1 parent 06ac7d3
José Valim authored December 08, 2011
5  actionpack/examples/performance.rb
... ...
@@ -1,5 +1,4 @@
1 1
 ENV['RAILS_ENV'] ||= 'production'
2  
-ENV['NO_RELOAD'] ||= '1'
3 2
 
4 3
 require File.expand_path('../../../load_paths', __FILE__)
5 4
 require 'action_pack'
@@ -77,6 +76,10 @@ def self.done
77 76
   end
78 77
 end
79 78
 
  79
+ActionController::Base.logger = nil
  80
+ActionController::Base.config.compile_methods!
  81
+ActionView::Resolver.caching = ENV["RAILS_ENV"] == "production"
  82
+
80 83
 class BasePostController < ActionController::Base
81 84
   append_view_path "#{File.dirname(__FILE__)}/views"
82 85
 
7  actionpack/lib/abstract_controller/rendering.rb
@@ -66,12 +66,7 @@ def protected_instance_variables
66 66
     end
67 67
 
68 68
     def view_context_class
69  
-      @_view_context_class || self.class.view_context_class
70  
-    end
71  
-
72  
-    def initialize(*)
73  
-      @_view_context_class = nil
74  
-      super
  69
+      @_view_context_class ||= self.class.view_context_class
75 70
     end
76 71
 
77 72
     # An instance of a view class. The default view class is ActionView::Base
18  actionpack/lib/action_view/lookup_context.rb
@@ -20,7 +20,7 @@ class LookupContext #:nodoc:
20 20
 
21 21
     def self.register_detail(name, options = {}, &block)
22 22
       self.registered_details << name
23  
-      initialize = registered_details.map { |n| "self.#{n} = details[:#{n}]" }
  23
+      initialize = registered_details.map { |n| "@details[:#{n}] = details[:#{n}] || default_#{n}" }
24 24
 
25 25
       Accessors.send :define_method, :"default_#{name}", &block
26 26
       Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1
@@ -29,7 +29,7 @@ def #{name}
29 29
         end
30 30
 
31 31
         def #{name}=(value)
32  
-          value = Array.wrap(value.presence || default_#{name})
  32
+          value = value.present? ? Array.wrap(value) : default_#{name}
33 33
           _set_detail(:#{name}, value) if value != @details[:#{name}]
34 34
         end
35 35
 
@@ -153,14 +153,14 @@ def normalize_name(name, prefixes) #:nodoc:
153 153
           ""
154 154
         end
155 155
 
156  
-        parts = name.split('/')
157  
-        name  = parts.pop
  156
+        prefixes = nil if prefixes.blank?
  157
+        parts    = name.split('/')
  158
+        name     = parts.pop
158 159
 
159  
-        prefixes = if prefixes.blank?
160  
-          [parts.join('/')]
161  
-        else
162  
-          prefixes.map { |prefix| [prefix, *parts].compact.join('/') }
163  
-        end
  160
+        return name, prefixes || [""] if parts.empty?
  161
+
  162
+        parts    = parts.join('/')
  163
+        prefixes = prefixes ? prefixes.map { |p| "#{p}/#{parts}" } : [parts]
164 164
 
165 165
         return name, prefixes
166 166
       end
2  actionpack/lib/action_view/template/resolver.rb
@@ -24,7 +24,7 @@ def initialize(name, prefix, partial, virtual)
24 24
       end
25 25
     end
26 26
 
27  
-    cattr_accessor :caching
  27
+    class_attribute :caching
28 28
     self.caching = true
29 29
 
30 30
     class << self

0 notes on commit efc28a7

Please sign in to comment.
Something went wrong with that request. Please try again.