rails/actionpack/lib
Aaron Patterson 01d88953e2 drop string allocations for each resource
Eagerly calculate and cache the name of Symbol objects in the path AST.
This drops about 26 string allocations per resource:

```ruby
require 'action_pack'
require 'action_dispatch'
require 'benchmark/ips'

route_set = ActionDispatch::Routing::RouteSet.new
routes = ActionDispatch::Routing::Mapper.new route_set

ObjectSpace::AllocationTracer.setup(%i{path line type})
result = ObjectSpace::AllocationTracer.trace do
  500.times do
    routes.resources :foo
  end
end

sorted = ObjectSpace::AllocationTracer.allocated_count_table.sort_by(&:last)
sorted.each do |k,v|
  next if v == 0
  p k => v
end

__END__

Before:

{:T_SYMBOL=>11}
{:T_REGEXP=>17}
{:T_STRUCT=>6500}
{:T_MATCH=>12004}
{:T_OBJECT=>99009}
{:T_DATA=>116084}
{:T_HASH=>122015}
{:T_STRING=>172647}
{:T_IMEMO=>371132}
{:T_ARRAY=>433056}

After:

{:T_SYMBOL=>11}
{:T_REGEXP=>17}
{:T_STRUCT=>6500}
{:T_MATCH=>12004}
{:T_OBJECT=>99009}
{:T_DATA=>100088}
{:T_HASH=>122015}
{:T_STRING=>159637}
{:T_IMEMO=>363134}
{:T_ARRAY=>433056}
```
2015-08-18 15:12:44 -07:00
..
abstract_controller Initialize symbols instead of mapping to_sym on the set of strings 2015-08-15 17:45:13 +02:00
action_controller Fix master build 2015-08-17 23:30:32 +02:00
action_dispatch drop string allocations for each resource 2015-08-18 15:12:44 -07:00
action_pack Start Rails 5 development 🎉 2014-11-28 15:00:06 -02:00
abstract_controller.rb No need for .rb extension 2013-08-25 11:39:09 +02:00
action_controller.rb Return 204 if render is not called in API controllers 2015-06-11 16:54:17 -03:00
action_dispatch.rb Soften the lock requirements when eager_load is disabled 2015-07-09 02:23:23 +09:30
action_pack.rb Update copyright notices to 2015 [ci skip] 2014-12-31 08:34:14 +01:00