1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

allocate a request object to avoid hash allocations

This decouples the `call` method from knowing the SCRIPT_NAME key and
offloads decisions about how to access script_name
This commit is contained in:
Aaron Patterson 2015-08-05 16:55:03 -07:00
parent a7fcb0e50a
commit df71e48be8
2 changed files with 6 additions and 3 deletions

View file

@ -118,6 +118,10 @@ module ActionDispatch
env[_routes.env_key]
end
def engine_script_name=(name) # :nodoc:
env[routes.env_key] = name.dup
end
def request_method=(request_method) #:nodoc:
if check_method(request_method)
@request_method = env["REQUEST_METHOD"] = request_method

View file

@ -519,9 +519,8 @@ module Rails
# Define the Rack API for this engine.
def call(env)
env.merge!(env_config)
if env['SCRIPT_NAME']
env[routes.env_key] = env['SCRIPT_NAME'].dup
end
req = ActionDispatch::Request.new env
req.engine_script_name = req.script_name
app.call(env)
end